Search in sources :

Example 11 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_77.

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

Example 12 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_69.

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

Example 13 with ParameterizedSparqlString

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

the class AbstractJenaStatementTests method prepared_statement_setters_54.

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

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

the class AbstractJenaStatementTests method prepared_statement_setters_33.

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

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

the class AbstractJenaStatementTests method prepared_statement_setters_20.

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