Search in sources :

Example 61 with ParameterizedSparqlString

use of org.apache.jena.query.ParameterizedSparqlString in project jena by apache.

the class AbstractJenaStatementTests method prepared_statement_setters_34.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_34() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setLong(1, 123l);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains("123"));
    stmt.close();
    conn.close();
}
Also used : ParameterizedSparqlString(org.apache.jena.query.ParameterizedSparqlString) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) Test(org.junit.Test)

Example 62 with ParameterizedSparqlString

use of org.apache.jena.query.ParameterizedSparqlString in project jena by apache.

the class AbstractJenaStatementTests method prepared_statement_setters_24.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_24() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setObject(1, ModelFactory.createDefaultModel().createResource("urn:x-arq:DefaultGraph"));
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains("<urn:x-arq:DefaultGraph>"));
    stmt.close();
    conn.close();
}
Also used : ParameterizedSparqlString(org.apache.jena.query.ParameterizedSparqlString) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) Test(org.junit.Test)

Example 63 with ParameterizedSparqlString

use of org.apache.jena.query.ParameterizedSparqlString in project jena by apache.

the class AbstractJenaStatementTests method prepared_statement_setters_38.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_38() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setObject(1, true, Types.BOOLEAN);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains("true"));
    stmt.close();
    conn.close();
}
Also used : ParameterizedSparqlString(org.apache.jena.query.ParameterizedSparqlString) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) Test(org.junit.Test)

Example 64 with ParameterizedSparqlString

use of org.apache.jena.query.ParameterizedSparqlString in project jena by apache.

the class AbstractJenaStatementTests method prepared_statement_setters_16.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_16() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setObject(1, IRIFactory.iriImplementation().create("http://example.org"), Types.JAVA_OBJECT);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains("<http://example.org>"));
    stmt.close();
    conn.close();
}
Also used : ParameterizedSparqlString(org.apache.jena.query.ParameterizedSparqlString) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) Test(org.junit.Test)

Example 65 with ParameterizedSparqlString

use of org.apache.jena.query.ParameterizedSparqlString in project jena by apache.

the class AbstractJenaStatementTests method prepared_statement_setters_78.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     * @throws URISyntaxException
     */
@Test
public void prepared_statement_setters_78() throws SQLException, URISyntaxException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setObject(1, new URI("http://example"), Types.JAVA_OBJECT);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains("<http://example>"));
    stmt.close();
    conn.close();
}
Also used : ParameterizedSparqlString(org.apache.jena.query.ParameterizedSparqlString) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) URI(java.net.URI) Test(org.junit.Test)

Aggregations

JenaConnection (org.apache.jena.jdbc.connections.JenaConnection)79 ParameterizedSparqlString (org.apache.jena.query.ParameterizedSparqlString)79 Test (org.junit.Test)79 Calendar (java.util.Calendar)8 URI (java.net.URI)2 URL (java.net.URL)2