use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method prepared_statement_setters_36.
/**
* Tests that the various set methods of {@link JenaPreparedStatement}
* function correctly
*
* @throws SQLException
*/
@Test
public void prepared_statement_setters_36() throws SQLException {
JenaConnection conn = this.getConnection();
JenaPreparedStatement stmt = (JenaPreparedStatement) conn.prepareStatement("SELECT * WHERE { ?s ?p ? }");
stmt.setObject(1, NodeFactoryExtra.intToNode(123l), Types.BIGINT);
ParameterizedSparqlString pss = stmt.getParameterizedString();
Assert.assertTrue(pss.toString().contains("123"));
stmt.close();
conn.close();
}
use of org.apache.jena.jdbc.connections.JenaConnection 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();
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method statement_closed_execute_02.
/**
* Tests error cases for trying to execute things on closed statements
*
* @throws SQLException
*/
@Test(expected = SQLException.class)
public void statement_closed_execute_02() throws SQLException {
JenaConnection conn = this.getConnection();
Statement stmt = conn.createStatement();
stmt.close();
try {
stmt.execute("SELECT * WHERE { ?s ?p ?o }", 0);
} finally {
conn.close();
}
}
use of org.apache.jena.jdbc.connections.JenaConnection 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();
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method prepared_statement_bad_setters_07.
/**
* Tests error cases for setters on prepared statements
*
* @throws SQLException
*/
@Test(expected = SQLException.class)
public void prepared_statement_bad_setters_07() throws SQLException {
JenaConnection conn = this.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT * WHERE { ? ?p ?o }");
try {
// Invalid cast
stmt.setObject(1, new Object(), Types.BOOLEAN);
} finally {
stmt.close();
conn.close();
}
}
Aggregations