Repository: karaf
Updated Branches:
refs/heads/karaf-2.3.x 270a72bf0 -> 9e18bdbac
[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/9e18bdba
Tree: http://git-wip-us.apache.org/repos/asf/karaf/tree/9e18bdba
Diff: http://git-wip-us.apache.org/repos/asf/karaf/diff/9e18bdba
Branch: refs/heads/karaf-2.3.x
Commit: 9e18bdbaca76ef39fd709c9cc8c50bfd5dbf1c47
Parents: 270a72b
Author: Jean-Baptiste Onofré <jbonofre@apache.org>
Authored: Wed Apr 1 11:16:05 2015 +0200
Committer: Jean-Baptiste Onofré <jbonofre@apache.org>
Committed: Wed Apr 1 11:16:05 2015 +0200
----------------------------------------------------------------------
.../org/apache/karaf/main/DefaultJDBCLock.java | 20 ++++++++++++--------
.../org/apache/karaf/main/BaseJDBCLockTest.java | 6 +++++-
.../src/main/webapp/users-guide/failover.conf | 1 +
3 files changed, 18 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/karaf/blob/9e18bdba/main/src/main/java/org/apache/karaf/main/DefaultJDBCLock.java
----------------------------------------------------------------------
diff --git a/main/src/main/java/org/apache/karaf/main/DefaultJDBCLock.java b/main/src/main/java/org/apache/karaf/main/DefaultJDBCLock.java
index 452fbe6..6eb8dac 100644
--- a/main/src/main/java/org/apache/karaf/main/DefaultJDBCLock.java
+++ b/main/src/main/java/org/apache/karaf/main/DefaultJDBCLock.java
@@ -18,12 +18,7 @@
*/
package org.apache.karaf.main;
-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 java.util.Properties;
import java.util.logging.Logger;
@@ -92,7 +87,7 @@ public class DefaultJDBCLock implements Lock {
createDatabase();
createSchema();
} catch (Exception e) {
- LOG.severe("Error occured while attempting to obtain connection: " + e);
+ LOG.severe("Error occurred while attempting to obtain connection: " + e);
}
}
@@ -128,8 +123,17 @@ public class DefaultJDBCLock implements Lock {
boolean schemaExists = false;
try {
- rs = getConnection().getMetaData().getTables(null, null, statements.getFullLockTableName(),
new String[] {"TABLE"});
+ DatabaseMetaData metadata = getConnection().getMetaData();
+ rs = metadata.getTables(null, null, statements.getFullLockTableName(), new String[]{"TABLE"});
schemaExists = rs.next();
+ if (!schemaExists) {
+ rs = metadata.getTables(null, null, statements.getFullLockTableName().toLowerCase(),
new String[]{"TABLE"});
+ schemaExists = rs.next();
+ }
+ if (!schemaExists) {
+ rs = metadata.getTables(null, null, statements.getFullLockTableName().toUpperCase(),
new String[]{"TABLE"});
+ schemaExists = rs.next();
+ }
} catch (Exception ignore) {
LOG.severe("Error testing for db table: " + ignore);
} finally {
http://git-wip-us.apache.org/repos/asf/karaf/blob/9e18bdba/main/src/test/java/org/apache/karaf/main/BaseJDBCLockTest.java
----------------------------------------------------------------------
diff --git a/main/src/test/java/org/apache/karaf/main/BaseJDBCLockTest.java b/main/src/test/java/org/apache/karaf/main/BaseJDBCLockTest.java
index 6589860..4f2160a 100644
--- a/main/src/test/java/org/apache/karaf/main/BaseJDBCLockTest.java
+++ b/main/src/test/java/org/apache/karaf/main/BaseJDBCLockTest.java
@@ -88,7 +88,11 @@ 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(), eq("LOCK_TABLE"),
aryEq(new String[]{"TABLE"}))).andReturn(resultSet);
+ expect(metaData.getTables((String) isNull(), (String) isNull(), eq("LOCK_TABLE"),
aryEq(new String[]{"TABLE"}))).andReturn(resultSet);
+ expect(metaData.getTables((String) isNull(), (String) isNull(), eq("lock_table"),
aryEq(new String[] {"TABLE"}))).andReturn(resultSet);
+ expect(resultSet.next()).andReturn(false);
+ expect(resultSet.next()).andReturn(false);
expect(resultSet.next()).andReturn(false);
resultSet.close();
expect(connection.isClosed()).andReturn(false);
http://git-wip-us.apache.org/repos/asf/karaf/blob/9e18bdba/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 f3b8f49..bd53fa8 100644
--- a/manual/src/main/webapp/users-guide/failover.conf
+++ b/manual/src/main/webapp/users-guide/failover.conf
@@ -48,6 +48,7 @@ karaf.lock.jdbc.timeout=30
* The "sample" database referred to above will be created if it does not exist.
* The first Karaf instance to acquire the locking table is the master instance.
* If the connection to the database is lost, the master instance tries to gracefully shutdown,
allowing a slave instance to become master when the database service is restored. The former
master will require a manual restart.
+* Karaf will first use the table name as defined in karaf.lock.jdbc.table property, it will
also try upper and lower case for the table name.
{warning}
Apache Karaf won't start if the JDBC driver is not present in the {{lib/ext}} folder.
|