private Connection connection = null;
@Before
- public void setUp() throws Exception
- {
+ public void setUp() throws Exception {
System.setProperty("sqlite.purejava", "true");
connection = null;
Class.forName("org.sqlite.JDBC");
}
@After
- public void tearDown() throws Exception
- {
+ public void tearDown() throws Exception {
if (connection != null)
connection.close();
+
+ System.setProperty("sqlite.purejava", "false");
}
@Test
- public void query() throws ClassNotFoundException
- {
+ public void query() throws ClassNotFoundException {
//_logger.debug(String.format("running in %s mode", SQLiteJDBCLoader.isNativeMode() ? "native" : "nested"));
assertTrue(SQLiteJDBCLoader.isNativeMode() == false);
- try
- {
+ try {
Statement statement = connection.createStatement();
statement.setQueryTimeout(30); // set timeout to 30 sec.
statement.executeUpdate("insert into person values(2, 'yui')");
ResultSet rs = statement.executeQuery("select * from person order by id");
- while (rs.next())
- {
+ while (rs.next()) {
// read the result set
int id = rs.getInt(1);
String name = rs.getString(2);
}
}
- catch (SQLException e)
- {
+ catch (SQLException e) {
// if e.getMessage() is "out of memory", it probably means no
// database file is found
fail(e.getMessage());
}
@Test
- public void function() throws SQLException
- {
+ public void function() throws SQLException {
assertTrue(SQLiteJDBCLoader.isNativeMode() == false);
Function.create(connection, "total", new Function() {
@Override
- protected void xFunc() throws SQLException
- {
+ protected void xFunc() throws SQLException {
int sum = 0;
for (int i = 0; i < args(); i++)
sum += value_int(i);