OPENJPA-1029 SQLServerDictionary updates contributed by Donald Woods

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@765841 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jeremy Bauer 2009-04-17 03:15:38 +00:00
parent e4b87fd6b3
commit d9039ca640
1 changed files with 55 additions and 31 deletions

View File

@ -64,25 +64,43 @@ public class SQLServerDictionary
public void connectedConfiguration(Connection conn) public void connectedConfiguration(Connection conn)
throws SQLException { throws SQLException {
super.connectedConfiguration(conn); super.connectedConfiguration(conn);
boolean requiresWarnings = true;
DatabaseMetaData meta = conn.getMetaData(); DatabaseMetaData meta = conn.getMetaData();
String driverName = meta.getDriverName(); String driverName = meta.getDriverName();
String url = meta.getURL(); String url = meta.getURL();
if (driverVendor == null) { if (driverVendor == null) {
if (driverName != null) {
if (driverName.startsWith("Microsoft SQL Server")) {
// v1.1, 1.2 or 2.0 driver
driverVendor = VENDOR_MICROSOFT;
// serverMajorVersion of 8==2000, 9==2005, 10==2008
if (meta.getDatabaseMajorVersion() >= 9)
supportsXMLColumn = true;
if (meta.getDriverMajorVersion() >= 2) {
// see http://blogs.msdn.com/jdbcteam/archive/2007/05/\
// 02/what-is-adaptive-response-buffering-and-why-\
// should-i-use-it.aspx
// 2.0 driver connectURL automatically includes
// responseBuffering=adaptive
// and disableStatementPooling=true
requiresWarnings = false;
}
} else {
if ("NetDirect JSQLConnect".equals(driverName)) if ("NetDirect JSQLConnect".equals(driverName))
driverVendor = VENDOR_NETDIRECT; driverVendor = VENDOR_NETDIRECT;
else if (driverName != null && driverName.startsWith("jTDS")) else if (driverName.startsWith("jTDS"))
driverVendor = VENDOR_JTDS; driverVendor = VENDOR_JTDS;
else if ("SQLServer".equals(driverName)) { else if ("SQLServer".equals(driverName)) {
if (url != null && url.startsWith("jdbc:microsoft:sqlserver:")) if (url != null &&
url.startsWith("jdbc:microsoft:sqlserver:"))
driverVendor = VENDOR_MICROSOFT; driverVendor = VENDOR_MICROSOFT;
else if (url != null else if (url != null
&& url.startsWith("jdbc:datadirect:sqlserver:")) && url.startsWith("jdbc:datadirect:sqlserver:"))
driverVendor = VENDOR_DATADIRECT; driverVendor = VENDOR_DATADIRECT;
else else
driverVendor = VENDOR_OTHER; driverVendor = VENDOR_OTHER;
} else }
driverVendor = VENDOR_OTHER; // old way of determining xml support
if (driverName.indexOf(platform) != -1) { if (driverName.indexOf(platform) != -1) {
String versionString = driverName. String versionString = driverName.
substring(platform.length() + 1); substring(platform.length() + 1);
@ -94,19 +112,25 @@ public class SQLServerDictionary
supportsXMLColumn = true; supportsXMLColumn = true;
} }
} }
} else {
driverVendor = VENDOR_OTHER;
}
}
// warn about using cursors // warn about not using cursors for pre-2.0 MS driver
if ((VENDOR_MICROSOFT.equalsIgnoreCase(driverVendor) // as connectURL includes selectMethod=direct
if (((VENDOR_MICROSOFT.equalsIgnoreCase(driverVendor)
&& requiresWarnings)
|| VENDOR_DATADIRECT.equalsIgnoreCase(driverVendor)) || VENDOR_DATADIRECT.equalsIgnoreCase(driverVendor))
&& url.toLowerCase().indexOf("selectmethod=cursor") == -1) && (url.toLowerCase().indexOf("selectmethod=cursor") == -1))
log.warn(_loc.get("sqlserver-cursor", url)); log.warn(_loc.get("sqlserver-cursor", url));
// warn about prepared statement caching if using ms driver // warn about prepared statement caching if using pre-2.0 MS drivers
// as connectURL includes responseBuffering=full
String props = conf.getConnectionFactoryProperties(); String props = conf.getConnectionFactoryProperties();
if (props == null) if ((props != null) &&
props = ""; VENDOR_MICROSOFT.equalsIgnoreCase(driverVendor) && requiresWarnings
if (VENDOR_MICROSOFT.equalsIgnoreCase(driverVendor) && (props.toLowerCase().indexOf("maxcachedstatements=0") == -1))
&& props.toLowerCase().indexOf("maxcachedstatements=0") == -1)
log.warn(_loc.get("sqlserver-cachedstmnts")); log.warn(_loc.get("sqlserver-cachedstmnts"));
} }