Commit 574f9c85 authored by Daniel Henninger's avatar Daniel Henninger Committed by dhenninger

[JM-1266] For databases that require FROM with all selects, we now have a...

[JM-1266] For databases that require FROM with all selects, we now have a mechanism for autmatically adjusting the default test SQL.

git-svn-id: http://svn.igniterealtime.org/svn/repos/openfire/trunk@9892 b35dd754-fafc-0310-a699-88a17e54d16e
parent 634ade79
......@@ -51,6 +51,10 @@ public class DbConnectionManager {
private static boolean scrollResultsSupported;
// True if the database supports batch updates.
private static boolean batchUpdatesSupported;
// True if the database supports the dual table.
private static boolean dualTableSupported;
// True if the database does not support select without from.
private static boolean selectRequiresFrom;
private static DatabaseType databaseType = DatabaseType.unknown;
......@@ -668,6 +672,8 @@ public class DbConnectionManager {
streamTextRequired = false;
maxRowsSupported = true;
fetchSizeSupported = true;
dualTableSupported = false;
selectRequiresFrom = false;
// Get the database name so that we can perform meta data settings.
String dbName = metaData.getDatabaseProductName().toLowerCase();
......@@ -678,6 +684,8 @@ public class DbConnectionManager {
databaseType = DatabaseType.oracle;
streamTextRequired = true;
scrollResultsSupported = false;
dualTableSupported = true;
selectRequiresFrom = true;
// The i-net AUGURO JDBC driver
if (driverName.indexOf("auguro") != -1) {
streamTextRequired = false;
......@@ -711,6 +719,7 @@ public class DbConnectionManager {
else if (dbName.indexOf("mysql") != -1) {
databaseType = DatabaseType.mysql;
transactionsSupported = false;
dualTableSupported = true;
}
// HSQL properties
else if (dbName.indexOf("hsql") != -1) {
......@@ -777,7 +786,6 @@ public class DbConnectionManager {
}
public static boolean isFetchSizeSupported() {
return fetchSizeSupported;
}
......@@ -793,6 +801,14 @@ public class DbConnectionManager {
return batchUpdatesSupported;
}
public static boolean isDualTableSupported() {
return dualTableSupported;
}
public static boolean doesSelectRequireFrom() {
return selectRequiresFrom;
}
public static boolean isEmbeddedDB() {
return connectionProvider != null && connectionProvider instanceof EmbeddedConnectionProvider;
}
......
......@@ -34,7 +34,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
private String password;
private int minConnections = 3;
private int maxConnections = 10;
private String testSQL = "select 1";
private String testSQL = "";
private Boolean testBeforeUse = true;
private Boolean testAfterUse = true;
......@@ -56,7 +56,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
public DefaultConnectionProvider() {
loadProperties();
System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory");
System.setProperty("org.apache.commons.logging.LogFactory", "org.jivesoftware.util.log.util.CommonsLogFactory");
}
public boolean isPooled() {
......@@ -317,6 +317,12 @@ public class DefaultConnectionProvider implements ConnectionProvider {
* Load properties that already exist from Jive properties.
*/
private void loadProperties() {
String defTestSQL = "select 1";
if (DbConnectionManager.isDualTableSupported() && DbConnectionManager.doesSelectRequireFrom()) {
defTestSQL = defTestSQL + " from dual";
}
driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver");
serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL");
username = JiveGlobals.getXMLProperty("database.defaultProvider.username");
......@@ -324,7 +330,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections");
String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections");
String conTimeout = JiveGlobals.getXMLProperty("database.defaultProvider.connectionTimeout");
testSQL = JiveGlobals.getXMLProperty("database.defaultProvider.testSQL", "select 1");
testSQL = JiveGlobals.getXMLProperty("database.defaultProvider.testSQL", defTestSQL);
testBeforeUse = JiveGlobals.getXMLProperty("database.defaultProvider.testBeforeUse", true);
testAfterUse = JiveGlobals.getXMLProperty("database.defaultProvider.testAfterUse", true);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment