use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaDriverTests method driver_config_precedence_01.
/**
* Tests the precedence rules for connection URL parameters
*
* @throws SQLException
*/
@Test
public void driver_config_precedence_01() throws SQLException {
String url = this.getConnectionUrl();
Assume.assumeNotNull(url);
url = url + "&" + JenaDriver.PARAM_PRE_PROCESSOR + "=" + Echo.class.getCanonicalName() + "&test=url";
JenaDriver driver = this.getDriver();
Properties ps = new Properties();
ps.put("test", "props");
JenaConnection conn = (JenaConnection) driver.connect(url, ps);
Iterator<CommandPreProcessor> preProcessors = conn.getPreProcessors();
Assert.assertTrue(preProcessors.hasNext());
Echo echo = (Echo) preProcessors.next();
Properties actual = echo.getProperties();
Assert.assertEquals("props", actual.getProperty("test"));
conn.close();
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method prepared_statement_bad_setters_10.
/**
* Tests error cases for setters on prepared statements
*
* @throws SQLException
*/
@Test(expected = SQLException.class)
public void prepared_statement_bad_setters_10() throws SQLException {
JenaConnection conn = this.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT * WHERE { ? ?p ?o }");
try {
// Invalid cast
stmt.setObject(1, new Object(), Types.DOUBLE);
} finally {
stmt.close();
conn.close();
}
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method statement_closed_execute_09.
/**
* Tests error cases for trying to execute things on closed statements
*
* @throws SQLException
*/
@Test(expected = SQLException.class)
public void statement_closed_execute_09() throws SQLException {
JenaConnection conn = this.getConnection();
Statement stmt = conn.createStatement();
stmt.close();
try {
stmt.executeUpdate("DELETE WHERE { ?s ?p ?o }", new int[0]);
} finally {
conn.close();
}
}
use of org.apache.jena.jdbc.connections.JenaConnection in project jena by apache.
the class AbstractJenaStatementTests method prepared_statement_bad_setters_05.
/**
* Tests error cases for setters on prepared statements
*
* @throws SQLException
*/
@Test(expected = SQLException.class)
public void prepared_statement_bad_setters_05() throws SQLException {
JenaConnection conn = this.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT * WHERE { ? ?p ?o }");
try {
// No RDF equivalent for unknown SQL Type
stmt.setObject(1, new Object(), Integer.MAX_VALUE);
} finally {
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_25.
/**
* Tests for unsupported setters on prepared statements
*
* @throws SQLException
*/
@Test(expected = SQLFeatureNotSupportedException.class)
public void prepared_statement_unsupported_setters_25() throws SQLException {
JenaConnection conn = this.getConnection();
PreparedStatement stmt = conn.prepareStatement("SELECT * WHERE { ? ?p ?o }");
try {
stmt.setNull(1, 0);
} finally {
stmt.close();
conn.close();
}
}
Aggregations