Commits

Grace Batumbya  committed 35df57d

Fixes #60: ExtendedCommand (e.g backup) not supported on Stmt.execute().

  • Participants
  • Parent commits 2144734

Comments (0)

Files changed (3)

 Work in progress:
 
+* Issue 60 - ExtendedCommand (e.g backup) not supported on stmt.execute()
 * Added support for specifying a date storage class. For more info <https://bitbucket.org/xerial/sqlite-jdbc/issue/23/getdate-returns-wrong-values>
 * Issue 23 - getDate() returns wrong values
 * Added support for InputStreams on PreparedStatement

File src/main/java/org/sqlite/Stmt.java

      */
     public boolean execute(String sql) throws SQLException {
         internalClose();
+
+        SQLExtension ext = ExtendedCommand.parse(sql);
+        if (ext != null) { 
+            ext.execute(db);
+
+            return false;
+        }
+
         this.sql = sql;
 
         db.prepare(this);

File src/test/java/org/sqlite/BackupTest.java

 
     @Test
     public void backupAndRestore() throws SQLException, IOException {
-
-        //if (!SQLiteJDBCLoader.isNativeMode())
-        //    return; // skip this test in pure-java mode
-
         // create a memory database
         File tmpFile = File.createTempFile("backup-test", ".sqlite");
         tmpFile.deleteOnExit();
         // open another memory database
         Connection conn2 = DriverManager.getConnection("jdbc:sqlite:");
         Statement stmt2 = conn2.createStatement();
-        stmt2.executeUpdate("restore from " + tmpFile.getAbsolutePath());
+        stmt2.execute("restore from " + tmpFile.getAbsolutePath());
         ResultSet rs = stmt2.executeQuery("select * from sample");
         int count = 0;
         while (rs.next()) {
         }
 
         assertEquals(2, count);
+        rs.close();
 
     }