Search in sources :

Example 26 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_43.

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

Example 27 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_18.

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

Example 28 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_79.

/**
     * Tests that the various set methods of {@link JenaPreparedStatement}
     * function correctly
     * 
     * @throws SQLException
     */
@Test
public void prepared_statement_setters_79() throws SQLException {
    JenaConnection conn = this.getConnection();
    JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
    Calendar c = Calendar.getInstance();
    stmt.setObject(1, c, Types.JAVA_OBJECT);
    ParameterizedSparqlString pss = stmt.getParameterizedString();
    Assert.assertTrue(pss.toString().contains(Integer.toString(c.get(Calendar.YEAR))));
    Assert.assertTrue(pss.toString().contains(XSDDatatype.XSDdateTime.getURI()));
    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 29 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_74.

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

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

the class AbstractJenaStatementTests method prepared_statement_setters_52.

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

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