empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject empire-db git commit: EMPIREDB-221 bugifx
Date Wed, 05 Aug 2015 11:37:32 GMT
Repository: empire-db
Updated Branches:
  refs/heads/master ba1d8264c -> 46d3e32e2


EMPIREDB-221
bugifx

Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo
Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/46d3e32e
Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/46d3e32e
Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/46d3e32e

Branch: refs/heads/master
Commit: 46d3e32e2d14d706192588773dc1a388d7e13e83
Parents: ba1d826
Author: Rainer Döbele <doebele@apache.org>
Authored: Wed Aug 5 13:37:28 2015 +0200
Committer: Rainer Döbele <doebele@apache.org>
Committed: Wed Aug 5 13:37:28 2015 +0200

----------------------------------------------------------------------
 .../db/sqlite/DBDatabaseDriverSQLite.java       | 45 ++++++++++++++++++++
 1 file changed, 45 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/empire-db/blob/46d3e32e/empire-db/src/main/java/org/apache/empire/db/sqlite/DBDatabaseDriverSQLite.java
----------------------------------------------------------------------
diff --git a/empire-db/src/main/java/org/apache/empire/db/sqlite/DBDatabaseDriverSQLite.java
b/empire-db/src/main/java/org/apache/empire/db/sqlite/DBDatabaseDriverSQLite.java
index 842942a..25eee0e 100644
--- a/empire-db/src/main/java/org/apache/empire/db/sqlite/DBDatabaseDriverSQLite.java
+++ b/empire-db/src/main/java/org/apache/empire/db/sqlite/DBDatabaseDriverSQLite.java
@@ -19,8 +19,10 @@
 package org.apache.empire.db.sqlite;
 
 import java.sql.Connection;
+import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.sql.Statement;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -404,6 +406,49 @@ public class DBDatabaseDriverSQLite extends DBDatabaseDriver
                 return "?";
         }
     }
+
+    @Override
+    public int executeSQL(String sqlCmd, Object[] sqlParams, Connection conn, DBSetGenKeys
genKeys) throws SQLException
+    {
+        Statement stmt = null;
+        int count = 0;
+        try
+        {
+            if (sqlParams != null)
+            { // Use a prepared statement
+                PreparedStatement pstmt = conn.prepareStatement(sqlCmd);
+                stmt = pstmt;
+                prepareStatement(pstmt, sqlParams);
+                count = pstmt.executeUpdate();
+            }
+            else
+            { // Execute a simple statement
+                stmt = conn.createStatement();
+                count = stmt.executeUpdate(sqlCmd);
+            }
+            // Retrieve any auto-generated keys
+            if (genKeys != null && count > 0)
+            { // Return Keys
+                ResultSet rs = stmt.getGeneratedKeys();
+                try
+                {
+                    while (rs.next())
+                    {
+                        genKeys.set(rs.getObject(1));
+                    }
+                }
+                finally
+                {
+                    rs.close();
+                }
+            }
+        }
+        finally
+        {
+            close(stmt);
+        }
+        return count;
+    }
     
     @Override
     public Object getResultValue(ResultSet rset, int columnIndex, DataType dataType) throws
SQLException


Mime
View raw message