karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbono...@apache.org
Subject karaf git commit: [KARAF-3562] Try to find the JDBC lock table name using upper and lower case in addition of the provided name
Date Tue, 31 Mar 2015 13:41:17 GMT
Repository: karaf
Updated Branches:
  refs/heads/karaf-3.0.x 1b044c6ad -> d5b0f4afd


[KARAF-3562] Try to find the JDBC lock table name using upper and lower case in addition of
the provided name


Project: http://git-wip-us.apache.org/repos/asf/karaf/repo
Commit: http://git-wip-us.apache.org/repos/asf/karaf/commit/d5b0f4af
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/d5b0f4af
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/d5b0f4af

Branch: refs/heads/karaf-3.0.x
Commit: d5b0f4afdf477dbb0305a0d872e012cc1ba28be0
Parents: 1b044c6
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Tue Mar 31 15:39:50 2015 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Tue Mar 31 15:39:50 2015 +0200

----------------------------------------------------------------------
 .../apache/karaf/main/lock/DefaultJDBCLock.java | 23 ++++++++++++++------
 .../karaf/main/lock/BaseJDBCLockTest.java       |  6 +++--
 .../src/main/webapp/users-guide/failover.conf   |  3 ++-
 3 files changed, 22 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/karaf/blob/d5b0f4af/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java
----------------------------------------------------------------------
diff --git a/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java b/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java
index aeb0a6a..31bf499 100644
--- a/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java
+++ b/main/src/main/java/org/apache/karaf/main/lock/DefaultJDBCLock.java
@@ -18,12 +18,8 @@
  */
 package org.apache.karaf.main.lock;
 
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
+import java.sql.*;
+
 import org.apache.felix.utils.properties.Properties;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -163,8 +159,21 @@ public class DefaultJDBCLock implements Lock {
         ResultSet rs = null;
         boolean schemaExists = false;
         try {
-            rs = getConnection().getMetaData().getTables(null, null, tableName, new String[]
{"TABLE"});
+            DatabaseMetaData metadata = getConnection().getMetaData();
+            rs = metadata.getTables(null, null, tableName, new String[] {"TABLE"});
             schemaExists = rs.next();
+            if (schemaExists == false) {
+                // try table name in lower case
+                rs = metadata.getTables(null, null, tableName.toLowerCase(), new String[]
{"TABLE"});
+                schemaExists = rs.next();
+            }
+            /*
+            if (schemaExists == false) {
+                // try table name in upper case
+                rs = getConnection().getMetaData().getTables(null, null, tableName.toUpperCase(),
new String[] {"TABLE"});
+                schemaExists = rs.next();
+            }
+            */
         } catch (Exception ignore) {
             LOG.log(Level.SEVERE, "Error testing for db table", ignore);
         } finally {

http://git-wip-us.apache.org/repos/asf/karaf/blob/d5b0f4af/main/src/test/java/org/apache/karaf/main/lock/BaseJDBCLockTest.java
----------------------------------------------------------------------
diff --git a/main/src/test/java/org/apache/karaf/main/lock/BaseJDBCLockTest.java b/main/src/test/java/org/apache/karaf/main/lock/BaseJDBCLockTest.java
index ea8b7c5..d352bf1 100644
--- a/main/src/test/java/org/apache/karaf/main/lock/BaseJDBCLockTest.java
+++ b/main/src/test/java/org/apache/karaf/main/lock/BaseJDBCLockTest.java
@@ -89,7 +89,9 @@ public abstract class BaseJDBCLockTest {
         expect(connection.isClosed()).andReturn(false);
         connection.setAutoCommit(false);
         expect(connection.getMetaData()).andReturn(metaData);
-        expect(metaData.getTables((String) isNull(), (String) isNull(), eq("LOCK_TABLE"),
aryEq(new String[] {"TABLE"}))).andReturn(resultSet);
+        expect(metaData.getTables((String) isNull(), (String) isNull(), anyString(), aryEq(new
String[]{"TABLE"}))).andReturn(resultSet);
+        expect(metaData.getTables((String) isNull(), (String) isNull(), anyString(), aryEq(new
String[]{"TABLE"}))).andReturn(resultSet);
+        expect(resultSet.next()).andReturn(false);
         expect(resultSet.next()).andReturn(false);
         resultSet.close();
         expect(connection.isClosed()).andReturn(false);
@@ -110,7 +112,7 @@ public abstract class BaseJDBCLockTest {
     public void initShouldNotCreateTheSchemaIfItAlreadyExists() throws Exception {
         connection.setAutoCommit(false);
         expect(connection.getMetaData()).andReturn(metaData);
-        expect(metaData.getTables((String) isNull(), (String) isNull(), eq("LOCK_TABLE"),
aryEq(new String[] {"TABLE"}))).andReturn(resultSet);
+        expect(metaData.getTables((String) isNull(), (String) isNull(), anyString(), aryEq(new
String[]{"TABLE"}))).andReturn(resultSet);
         expect(resultSet.next()).andReturn(true);
         resultSet.close();
         

http://git-wip-us.apache.org/repos/asf/karaf/blob/d5b0f4af/manual/src/main/webapp/users-guide/failover.conf
----------------------------------------------------------------------
diff --git a/manual/src/main/webapp/users-guide/failover.conf b/manual/src/main/webapp/users-guide/failover.conf
index 3ad7d1b..c56a7c6 100644
--- a/manual/src/main/webapp/users-guide/failover.conf
+++ b/manual/src/main/webapp/users-guide/failover.conf
@@ -80,7 +80,8 @@ karaf.lock.jdbc.timeout=30
 * {{karaf.lock.jdbc.driver}} property contains the class name of the JDBC driver to use (derby
in this example).
 * {{karaf.lock.jdbc.user}} property contains the username to use to connect to the database.
 * {{karaf.lock.jdbc.password}} property contains the password to use to connet to the database.
-* {{karaf.lock.jdbc.table}} property contains the database table to use for the lock.
+* {{karaf.lock.jdbc.table}} property contains the database table to use for the lock. Karaf
will first try to find the table as specified in this property,
+  and if not found, it will try the table name in lower and upper case.
 
 {warning}
 Apache Karaf won't start if the JDBC driver is not present in the {{lib/ext}} folder.


Mime
View raw message