use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method statement_closed_results_01.
/**
* Tests error cases for trying to access results on closed statements
*
* @throws SQLException
*/
@Test(expected = SQLException.class)
public void statement_closed_results_01() throws SQLException {
JenaConnection conn = this.getConnection();
Statement stmt = conn.createStatement();
stmt.close();
try {
stmt.getResultSet();
} finally {
conn.close();
}
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method statement_metadata_02.
/**
* Tests getting metadata from the statement
*
* @throws SQLException
*/
@Test
public void statement_metadata_02() throws SQLException {
JenaConnection conn = this.getConnection();
Statement stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT);
Assert.assertEquals(ResultSet.TYPE_SCROLL_INSENSITIVE, stmt.getResultSetType());
Assert.assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, stmt.getResultSetHoldability());
Assert.assertEquals(ResultSet.CONCUR_READ_ONLY, stmt.getResultSetConcurrency());
}
use of org.apache.jena.jdbc.connections.JenaConnection 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();
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method prepared_statement_unsupported_setters_31.
/**
* Tests for unsupported setters on prepared statements
*
* @throws SQLException
*/
@Test(expected = SQLFeatureNotSupportedException.class)
public void prepared_statement_unsupported_setters_31() throws SQLException {
JenaConnection conn = this.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT * WHERE { ? ?p ?o }");
try {
stmt.setTime(1, null, null);
} finally {
stmt.close();
conn.close();
}
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method statement_warnings_05.
/**
* Check warnings usage
*
* @throws SQLException
*/
@Test
public void statement_warnings_05() throws SQLException {
JenaConnection conn = this.getConnection();
JenaStatement stmt = (JenaStatement) conn.createStatement();
Assert.assertNull(stmt.getWarnings());
stmt.setWarning("A");
Assert.assertNotNull(stmt.getWarnings());
stmt.setWarning("B");
Assert.assertNotNull(stmt.getWarnings());
Assert.assertNotNull(stmt.getWarnings().getNextWarning());
stmt.clearWarnings();
Assert.assertNull(stmt.getWarnings());
stmt.close();
conn.close();
}
Aggregations