@Override public Void call() throws Exception { connection.dispose(); return null; } }));
@Override public Void call() throws Exception { connection.dispose(); return null; } });
@Override public void teardown() { db.dispose(); }
/** * close the connection to avoid memory leaks. */ public void close() { this.connection.dispose(); }
@Override public Void call() throws Exception { connection.dispose(); return null; } });
@Override public Void call() throws Exception { connection.dispose(); return null; } }));
@Override public Void call() throws Exception { connection.dispose(); return null; } });
@Override public Void call() throws Exception { connection.dispose(); return null; } }));
/** * close the connection to avoid memory leaks. */ public void close() { this.connection.dispose(); }
@Override public void teardown() { db.dispose(); }
@Override public Object call() throws Exception { SQLiteConnection connection = getConnection(ptr); connection.dispose(); return null; } });
@Override public void close() { // it's not possible to call dispose from other threads // so the best we can do is call dispose on the connection // for the same thread as us SQLiteConnection conn = localConnection; if (conn != null && !conn.isDisposed()) { conn.dispose(); } }
@Override public Object call() throws Exception { SQLiteConnection connection = getConnection(ptr); connection.dispose(); return null; } });
public void close() { String thisThread = Thread.currentThread().getName(); for(ThreadAndConnection tConn: allOpenedConnections) { if(thisThread.equals(tConn.threadName)) { log.info("-- Closing my own connection to: " + tConn.conn.getDatabaseFile()); tConn.conn.dispose(); } else { // needs to be closed at some point by the owner Set<SQLiteConnection> set = CLEAN_UP_AFTER_YOURSELF.get(tConn.threadName); synchronized(set) { // just in case the owner of the set is iterating over it CLEAN_UP_AFTER_YOURSELF.get(tConn.threadName).add(tConn.conn); } } } // timeoutThread.interrupt(); } }
public void close() { String thisThread = Thread.currentThread().getName(); for (ThreadAndConnection tConn : allOpenedConnections) { if (thisThread.equals(tConn.threadName)) { log.info("-- Closing my own connection to: " + tConn.conn.getDatabaseFile()); tConn.conn.dispose(); } else { // needs to be closed at some point by the owner Set<SQLiteConnection> set = CLEAN_UP_AFTER_YOURSELF.get(tConn.threadName); synchronized (set) { // just in case the owner of the set is iterating // over it CLEAN_UP_AFTER_YOURSELF.get(tConn.threadName).add(tConn.conn); } } } // timeoutThread.interrupt(); } }
@Override public void close() throws IOException, InterruptedException { try { for (Map.Entry<Integer, SQLiteConnection> entry : connCache.entrySet()) { LOG.info("Closing SQL connection [" + entry.getKey() + "]"); // entry.getValue().exec("COMMIT"); if (getPostSQL() != null) { LOG.info("Executing end SQL statements."); for (String sql : getPostSQL()) { LOG.info("Executing: " + sql); entry.getValue().exec(sql); } } entry.getValue().dispose(); } } catch (SQLiteException e) { throw new IOException(e); } catch (SploutSQLOutputFormatException e) { throw new IOException(e); } } }
/** * Disposes the connection. Override to change how connection is disposed. * * @param connection database connection no longer in use by the queue */ protected void disposeConnection(SQLiteConnection connection) { try { if (connection != null) { if (Internal.isFineLogging()) { Internal.logFine(this, "disposing " + connection); } connection.dispose(); } } catch (Exception e) { Internal.log(Level.SEVERE, this, "error disposing connection", e); } }
SQLiteConnection db = new SQLiteConnection(new File("/tmp/database")); db.open(true); ... SQLiteStatement st = db.prepare("SELECT order_id FROM orders WHERE quantity >= ?"); try { st.bind(1, minimumQuantity); while (st.step()) { orders.add(st.columnLong(0)); } } finally { st.dispose(); } ... db.dispose();
SQLiteConnection sqLiteConnection=null; SQLiteStatement sqLiteStatement=null; try { File databaseFile = context.getDatabasePath("database.db"); sqLiteConnection=new SQLiteConnection(databaseFile); sqLiteConnection.open(); sqLiteStatement=sqLiteConnection.prepare("SELECT blob FROM table WHERE id=?"); sqLiteStatement.bind(1, id); sqLiteStatement.step(); byte[] blob=sqLiteStatement.columnBlob(0); } finally { if(sqLiteStatement!=null) sqLiteStatement.dispose(); if(sqLiteConnection!=null) sqLiteConnection.dispose(); }