Commits

Joel Carranza committed d97c1cd

Throw SQLException on call to Statement.setEscapeProcessing(true)

Driver does not implement escape processing

Comments (0)

Files changed (4)

src/main/java/org/sqlite/PrepStmt.java

     public void addBatch(String sql) throws SQLException {
         throw unused();
     }
-
-    /**
-     * @return An SQLiteException with the error message.
-     */
-    private SQLException unused() {
-        return new SQLException("not supported by PreparedStatment");
-    }
 }

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

      * @see java.sql.Statement#setEscapeProcessing(boolean)
      */
     public void setEscapeProcessing(boolean enable) throws SQLException {
-        // Escape processing is not implemented so this method is a no-op
+        if(enable) {
+          throw unused();
+        }
     }
 
 }

src/main/java/org/sqlite/Unused.java

  */
 abstract class Unused
 {
-    private SQLException unused() {
+    protected SQLException unused() {
         return new SQLException("not implemented by SQLite JDBC driver");
     }
 

src/test/java/org/sqlite/StatementTest.java

     public void maxRows() throws SQLException {
         stat.setMaxRows(1);
     }
+
+    @Test 
+    public void setEscapeProcessingToFals() throws SQLException {
+        stat.setEscapeProcessing(false);
+    }
+
+    @Test(expected=SQLException.class) 
+    public void setEscapeProcessingToTrue() throws SQLException {
+        stat.setEscapeProcessing(true);
+    }
 }