Commit 23d6c866 authored by Matt Tucker's avatar Matt Tucker Committed by matt

Fixed SQLServer detection, general clean-up.

git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@2897 b35dd754-fafc-0310-a699-88a17e54d16e
parent 35bbb452
...@@ -390,9 +390,12 @@ public class DbConnectionManager { ...@@ -390,9 +390,12 @@ public class DbConnectionManager {
} }
finally { finally {
try { try {
if (bodyReader != null) {
bodyReader.close(); bodyReader.close();
} }
}
catch (Exception e) { catch (Exception e) {
// Ignore.
} }
} }
return value; return value;
...@@ -416,7 +419,7 @@ public class DbConnectionManager { ...@@ -416,7 +419,7 @@ public class DbConnectionManager {
String value) throws SQLException String value) throws SQLException
{ {
if (isStreamTextRequired()) { if (isStreamTextRequired()) {
Reader bodyReader = null; Reader bodyReader;
try { try {
bodyReader = new StringReader(value); bodyReader = new StringReader(value);
pstmt.setCharacterStream(parameterIndex, bodyReader, value.length()); pstmt.setCharacterStream(parameterIndex, bodyReader, value.length());
...@@ -538,14 +541,15 @@ public class DbConnectionManager { ...@@ -538,14 +541,15 @@ public class DbConnectionManager {
fetchSizeSupported = false; fetchSizeSupported = false;
maxRowsSupported = false; maxRowsSupported = false;
} }
// SQLServer, JDBC driver i-net UNA properties // SQLServer
else if (dbName.indexOf("sql server") != -1 && else if (dbName.indexOf("sql server") != -1) {
driverName.indexOf("una") != -1)
{
databaseType = DatabaseType.sqlserver; databaseType = DatabaseType.sqlserver;
// JDBC driver i-net UNA properties
if (driverName.indexOf("una") != -1) {
fetchSizeSupported = true; fetchSizeSupported = true;
maxRowsSupported = false; maxRowsSupported = false;
} }
}
// MySQL properties // MySQL properties
else if (dbName.indexOf("mysql") != -1) { else if (dbName.indexOf("mysql") != -1) {
databaseType = DatabaseType.mysql; databaseType = DatabaseType.mysql;
...@@ -655,7 +659,7 @@ public class DbConnectionManager { ...@@ -655,7 +659,7 @@ public class DbConnectionManager {
interbase, interbase,
unknown; unknown
} }
/** /**
...@@ -714,14 +718,14 @@ public class DbConnectionManager { ...@@ -714,14 +718,14 @@ public class DbConnectionManager {
// Run all upgrade scripts until we're up to the latest schema. // Run all upgrade scripts until we're up to the latest schema.
for (int i=minorVersion; i<CURRENT_MINOR_VERSION; i++) { for (int i=minorVersion; i<CURRENT_MINOR_VERSION; i++) {
BufferedReader in = null; BufferedReader in = null;
Statement stmt = null; Statement stmt;
try { try {
// Resource will be like "/database/upgrade/2.0_to_2.1/messenger_hsqldb.sql" // Resource will be like "/database/upgrade/2.0_to_2.1/messenger_hsqldb.sql"
String resourceName = "/database/upgrade/" + CURRENT_MAJOR_VERSION + "." + i + String resourceName = "/database/upgrade/" + CURRENT_MAJOR_VERSION + "." + i +
"_to_" + CURRENT_MAJOR_VERSION + "." + (i+1) + "/messenger_" + "_to_" + CURRENT_MAJOR_VERSION + "." + (i+1) + "/messenger_" +
databaseType + ".sql"; databaseType + ".sql";
in = new BufferedReader(new InputStreamReader( in = new BufferedReader(new InputStreamReader(
new DbConnectionManager().getClass().getResourceAsStream(resourceName))); DbConnectionManager.class.getResourceAsStream(resourceName)));
boolean done = false; boolean done = false;
while (!done) { while (!done) {
StringBuilder command = new StringBuilder(); StringBuilder command = new StringBuilder();
...@@ -752,7 +756,9 @@ public class DbConnectionManager { ...@@ -752,7 +756,9 @@ public class DbConnectionManager {
catch (Exception e) { Log.error(e); } catch (Exception e) { Log.error(e); }
if (in != null) { if (in != null) {
try { in.close(); } try { in.close(); }
catch (Exception e) { } catch (Exception e) {
// Ignore.
}
} }
} }
} }
...@@ -778,12 +784,8 @@ public class DbConnectionManager { ...@@ -778,12 +784,8 @@ public class DbConnectionManager {
// "#" is MySQL // "#" is MySQL
// "REM" is Oracle // "REM" is Oracle
// "/*" is SQLServer // "/*" is SQLServer
if (line.startsWith("//") || line.startsWith("--") || line.startsWith("#") || return !(line.startsWith("//") || line.startsWith("--") || line.startsWith("#") ||
line.startsWith("REM") || line.startsWith("/*") || line.startsWith("*")) line.startsWith("REM") || line.startsWith("/*") || line.startsWith("*"));
{
return false;
}
return true;
} }
private DbConnectionManager() { private DbConnectionManager() {
......
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