Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try {
- Connection conn = db.getConnection() ;
- StringBuilder sql = new StringBuilder() ;
- sql.append("VACUUM");
- //PreparedStatement prep = conn.prepareStatement(sql.toString()) ;
- Statement stat = conn.createStatement() ;
- boolean rs = stat.execute(sql.toString()) ;
- System.out.println("Executed vacuum " + rs ) ;
- //Testing code--preparedstatement attempts
- //conn.setAutoCommit(false);
- //boolean rs = prep.execute() ;
- //conn.setAutoCommit(true);
- } catch (Exception e) {
- //Edited back in after posting to StackOverflow
- System.out.println(
- ".SQLiteVacuum :: exception " +
- e.getMessage() + " " + e.getClass().getName() );
- e.printStackTrace() ;
- }
- private final String dbJDBCdriverclassname = "org.sqlite.JDBC" ;
- private final String dbJDBCpreconnectionstring = "jdbc:sqlite:" ;
- // Setup the driver reference
- Class.forName(dbJDBCdriverclassname) ; //"org.sqlite.JDBC"
- // Create the connection string
- String connstring = dbJDBCpreconnectionstring + this.getDBConnectionFullFileName() ;
- // create the connection
- dbconnection =
- DriverManager.getConnection(connstring) ; // "jdbc:sqlite:test.db"
- Statement stmt = null;
- ResultSet rs = null;
- try {
- Connection conn = DBConnection.getConnection();//something to get a connection
- stmt = conn.createStatement();
- stmt.executeUpdate("VACUUM");
- } catch (SQLException ex) {
- //Something if you like, or not you're the boss!
- } finally {
- DBConnection.closeResources(rs, stmt);//something to close all the resources
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement