Search in sources :

Example 1 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_02.

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

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

the class AbstractJenaStatementTests method prepared_statement_setters_58.

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

Example 3 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_55.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_55() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    stmt.setObject(1, (byte) 123, Types.SMALLINT);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains("123"));
    Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDshort.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 4 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_62.

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

Example 5 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_57.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_57() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    Calendar c = Calendar.getInstance();
    stmt.setObject(1, c, Types.TIME);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.HOUR_OF_DAY))));
    stmt.close();
    conn.close();
}
Also used : Calendar(java.util.Calendar) 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