Search in sources :

Example 21 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_15.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_15() 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.NVARCHAR);
    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 22 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_76.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_76() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setObject(1, true, Types.JAVA_OBJECT);
    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 23 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_17.

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

Example 24 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_51.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_51() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setObject(1, (short) 123, Types.INTEGER);
    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 25 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_30.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_30() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setByte(1, (byte) 123);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains("123"));
    Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDbyte.getURI()));
    stmt.close();
    conn.close();
}
Also used : ParameterizedSparqlString(org.apache.jena.query.ParameterizedSparqlString) JenaConnection(org.apache.jena.jdbc.connections.JenaConnection) 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