OPENJPA-1759 Use new DATETIME2 type in MSSQL2008 for new tables with DATE or TIMESTAMP columns, but 3.0 driver still doesn't handle 2.0 created tables with DATETIME columns....

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@1030235 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Donald Woods 2010-11-02 21:28:23 +00:00
parent 2ca9d9f30f
commit eb2bf2acce
2 changed files with 12 additions and 2 deletions

View File

@ -79,6 +79,7 @@ public abstract class AbstractSQLServerDictionary
"IMAGE", "TEXT", "NTEXT", "MONEY", "SMALLMONEY", "INT",
"DOUBLE PRECISION", "DATETIME", "SMALLDATETIME",
"EXTENDED TYPE", "SYSNAME", "SQL_VARIANT", "INDEX",
"DATETIME2",
}));
}

View File

@ -22,9 +22,12 @@ import java.sql.Blob;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.Calendar;
import java.util.Set;
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
@ -74,7 +77,7 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
if (driverVendor == null) {
if (driverName != null) {
if (driverName.startsWith("Microsoft SQL Server")) {
// v1.1, 1.2 or 2.0 driver
// v1.1, 1.2, 2.0 or 3.0 driver
driverVendor = VENDOR_MICROSOFT;
// serverMajorVersion of 8==2000, 9==2005, 10==2008
if (meta.getDatabaseMajorVersion() >= 9)
@ -88,6 +91,13 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
// and disableStatementPooling=true
requiresWarnings = false;
}
if (meta.getDatabaseMajorVersion() >= 10) {
// MSSQL 2008 supports new date, time and datetime2 types
// Use DATETIME2 which has 100ns vs. 3.333msec precision
dateTypeName = "DATETIME2";
timeTypeName = "DATETIME";
timestampTypeName = "DATETIME2";
}
} else {
if ("NetDirect JSQLConnect".equals(driverName))
driverVendor = VENDOR_NETDIRECT;
@ -321,5 +331,4 @@ public class SQLServerDictionary extends AbstractSQLServerDictionary {
return clob.getCharacterStream();
}
}