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 { ...@@ -51,6 +51,10 @@ public class DbConnectionManager {
private static boolean scrollResultsSupported; private static boolean scrollResultsSupported;
// True if the database supports batch updates. // True if the database supports batch updates.
private static boolean batchUpdatesSupported; 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; private static DatabaseType databaseType = DatabaseType.unknown;
...@@ -668,6 +672,8 @@ public class DbConnectionManager { ...@@ -668,6 +672,8 @@ public class DbConnectionManager {
streamTextRequired = false; streamTextRequired = false;
maxRowsSupported = true; maxRowsSupported = true;
fetchSizeSupported = true; fetchSizeSupported = true;
dualTableSupported = false;
selectRequiresFrom = false;
// Get the database name so that we can perform meta data settings. // Get the database name so that we can perform meta data settings.
String dbName = metaData.getDatabaseProductName().toLowerCase(); String dbName = metaData.getDatabaseProductName().toLowerCase();
...@@ -678,6 +684,8 @@ public class DbConnectionManager { ...@@ -678,6 +684,8 @@ public class DbConnectionManager {
databaseType = DatabaseType.oracle; databaseType = DatabaseType.oracle;
streamTextRequired = true; streamTextRequired = true;
scrollResultsSupported = false; scrollResultsSupported = false;
dualTableSupported = true;
selectRequiresFrom = true;
// The i-net AUGURO JDBC driver // The i-net AUGURO JDBC driver
if (driverName.indexOf("auguro") != -1) { if (driverName.indexOf("auguro") != -1) {
streamTextRequired = false; streamTextRequired = false;
...@@ -711,6 +719,7 @@ public class DbConnectionManager { ...@@ -711,6 +719,7 @@ public class DbConnectionManager {
else if (dbName.indexOf("mysql") != -1) { else if (dbName.indexOf("mysql") != -1) {
databaseType = DatabaseType.mysql; databaseType = DatabaseType.mysql;
transactionsSupported = false; transactionsSupported = false;
dualTableSupported = true;
} }
// HSQL properties // HSQL properties
else if (dbName.indexOf("hsql") != -1) { else if (dbName.indexOf("hsql") != -1) {
...@@ -777,7 +786,6 @@ public class DbConnectionManager { ...@@ -777,7 +786,6 @@ public class DbConnectionManager {
} }
public static boolean isFetchSizeSupported() { public static boolean isFetchSizeSupported() {
return fetchSizeSupported; return fetchSizeSupported;
} }
...@@ -793,6 +801,14 @@ public class DbConnectionManager { ...@@ -793,6 +801,14 @@ public class DbConnectionManager {
return batchUpdatesSupported; return batchUpdatesSupported;
} }
public static boolean isDualTableSupported() {
return dualTableSupported;
}
public static boolean doesSelectRequireFrom() {
return selectRequiresFrom;
}
public static boolean isEmbeddedDB() { public static boolean isEmbeddedDB() {
return connectionProvider != null && connectionProvider instanceof EmbeddedConnectionProvider; return connectionProvider != null && connectionProvider instanceof EmbeddedConnectionProvider;
} }
......
...@@ -34,7 +34,7 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -34,7 +34,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
private String password; private String password;
private int minConnections = 3; private int minConnections = 3;
private int maxConnections = 10; private int maxConnections = 10;
private String testSQL = "select 1"; private String testSQL = "";
private Boolean testBeforeUse = true; private Boolean testBeforeUse = true;
private Boolean testAfterUse = true; private Boolean testAfterUse = true;
...@@ -56,7 +56,7 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -56,7 +56,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
public DefaultConnectionProvider() { public DefaultConnectionProvider() {
loadProperties(); 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() { public boolean isPooled() {
...@@ -317,6 +317,12 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -317,6 +317,12 @@ public class DefaultConnectionProvider implements ConnectionProvider {
* Load properties that already exist from Jive properties. * Load properties that already exist from Jive properties.
*/ */
private void loadProperties() { private void loadProperties() {
String defTestSQL = "select 1";
if (DbConnectionManager.isDualTableSupported() && DbConnectionManager.doesSelectRequireFrom()) {
defTestSQL = defTestSQL + " from dual";
}
driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver"); driver = JiveGlobals.getXMLProperty("database.defaultProvider.driver");
serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL"); serverURL = JiveGlobals.getXMLProperty("database.defaultProvider.serverURL");
username = JiveGlobals.getXMLProperty("database.defaultProvider.username"); username = JiveGlobals.getXMLProperty("database.defaultProvider.username");
...@@ -324,7 +330,7 @@ public class DefaultConnectionProvider implements ConnectionProvider { ...@@ -324,7 +330,7 @@ public class DefaultConnectionProvider implements ConnectionProvider {
String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections"); String minCons = JiveGlobals.getXMLProperty("database.defaultProvider.minConnections");
String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections"); String maxCons = JiveGlobals.getXMLProperty("database.defaultProvider.maxConnections");
String conTimeout = JiveGlobals.getXMLProperty("database.defaultProvider.connectionTimeout"); 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); testBeforeUse = JiveGlobals.getXMLProperty("database.defaultProvider.testBeforeUse", true);
testAfterUse = JiveGlobals.getXMLProperty("database.defaultProvider.testAfterUse", 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