Skip to content

Commit

Permalink
NXP-19714 integrated with MSSQL jdbc driver
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephane Lacoin aka nxmatic authored and nuxeojenkins committed May 26, 2016
1 parent 896cdbd commit 6929cb2
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 12 deletions.
Expand Up @@ -54,7 +54,7 @@ public class DatabaseSQLServer extends DatabaseHelper {

// true for the Microsoft JDBC driver
// false for the jTDS JDBC driver (open source)
private static final boolean MSFT = false;
private static final boolean MSFT = true;

private static final String DRIVER = MSFT ? "com.microsoft.sqlserver.jdbc.SQLServerDriver"
: "net.sourceforge.jtds.jdbc.Driver";
Expand All @@ -73,13 +73,13 @@ private void setProperties() {
setProperty(DRIVER_PROPERTY, DRIVER);
String url;
if (DRIVER.startsWith("com.microsoft")) {
url = String.format("jdbc:sqlserver://%s:%s;databaseName=%s;user=%s;password=%s",
url = String.format("jdbc:sqlserver://%s:%s;databaseName=%s;user=%s;password=%s;selectMethod=cursor",
Framework.getProperty(SERVER_PROPERTY), Framework.getProperty(PORT_PROPERTY),
Framework.getProperty(DATABASE_PROPERTY), Framework.getProperty(USER_PROPERTY),
Framework.getProperty(PASSWORD_PROPERTY));

} else {
url = String.format("jdbc:jtds:sqlserver://%s:%s;databaseName=%s;user=%s;password=%s",
url = String.format("jdbc:jtds:sqlserver://%s:%s;databaseName=%s;user=%s;password=%s;useCursors=true",
Framework.getProperty(SERVER_PROPERTY), Framework.getProperty(PORT_PROPERTY),
Framework.getProperty(DATABASE_PROPERTY), Framework.getProperty(USER_PROPERTY),
Framework.getProperty(PASSWORD_PROPERTY));
Expand Down Expand Up @@ -122,7 +122,7 @@ public String getDeploymentContrib() {
public RepositoryDescriptor getRepositoryDescriptor() {
RepositoryDescriptor descriptor = new RepositoryDescriptor();
descriptor.xaDataSourceName = XA_DATASOURCE;
Map<String, String> properties = new HashMap<String, String>();
Map<String, String> properties = new HashMap<>();
properties.put("ServerName", Framework.getProperty(SERVER_PROPERTY));
properties.put("PortNumber", Framework.getProperty(PORT_PROPERTY));
properties.put("DatabaseName", Framework.getProperty(DATABASE_PROPERTY));
Expand All @@ -148,7 +148,7 @@ public void sleepForFulltext() {
protected void checkSupports(Connection connection) throws SQLException {
Statement st = connection.createStatement();
try {
ResultSet rs = st.executeQuery("SELECT SERVERPROPERTY('ProductVersion'), CONVERT(NVARCHAR(100), SERVERPROPERTY('EngineEdition'))");
ResultSet rs = st.executeQuery("SELECT CONVERT(NVARCHAR(100),SERVERPROPERTY('ProductVersion')), CONVERT(NVARCHAR(100), SERVERPROPERTY('EngineEdition'))");
rs.next();
String productVersion = rs.getString(1);
/** 9 = SQL Server 2005, 10 = SQL Server 2008, 11 = SQL Server 2012 / Azure */
Expand Down
19 changes: 18 additions & 1 deletion nuxeo-core/nuxeo-core-storage-sql/nuxeo-core-storage-sql/pom.xml
Expand Up @@ -109,6 +109,23 @@
<scope>test</scope>
</dependency>
</dependencies>
<profiles>
<profile>
<id>multidb</id>

This comment has been minimized.

Copy link
@jcarsique

jcarsique May 27, 2016

Contributor

What is it used for?
That name is also likely to be used in QA (=> possible conflict).

The sqljdbc dependency must not be added here but in https://github.com/nuxeo/nuxeo/blob/master/nuxeo-core/nuxeo-core-storage-sql/nuxeo-core-storage-sql-test/pom.xml#L167

This comment has been minimized.

Copy link
@efge

efge May 27, 2016

Member

nuxeo-platform-directory-sql also uses the drivers (when in tests) and depends just on nuxeo-core-storage-sql

<dependencies>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc</artifactId>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<scope>compile</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<build>
<plugins>
<plugin>
Expand All @@ -123,4 +140,4 @@
</plugin>
</plugins>
</build>
</project>
</project>
4 changes: 2 additions & 2 deletions nuxeo-distribution/nuxeo-distribution-resources/pom.xml
Expand Up @@ -20,8 +20,8 @@
<classifier>jar-with-dependencies</classifier>
</dependency>
<dependency>
<groupId>net.sourceforge.jtds</groupId>
<artifactId>jtds</artifactId>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc</artifactId>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
Expand Down
Expand Up @@ -73,7 +73,7 @@
<param name="distribution" value="${distribution}" />
</antcall>
<copy todir="${outdir}/${distribution}/mssql/lib">
<artifact:file artifactId="jtds" />
<artifact:file groupId="com.microsoft.sqlserver" artifactId="sqljdbc" />
</copy>
<copy todir="${outdir}/${distribution}/mysql/lib">
<artifact:file artifactId="mysql-connector-java" />
Expand Down
Expand Up @@ -8,7 +8,7 @@ nuxeo.db.port=1433
nuxeo.db.name=nuxeo
nuxeo.db.user=nuxeo
nuxeo.db.password=password
nuxeo.db.jdbc.url=jdbc:jtds:sqlserver://${nuxeo.db.host}:${nuxeo.db.port}/${nuxeo.db.name};useCursors=true
nuxeo.db.driver=net.sourceforge.jtds.jdbc.Driver
nuxeo.db.xadatasource=net.sourceforge.jtds.jdbcx.JtdsDataSource
nuxeo.db.jdbc.url=jdbc:sqlserver://${nuxeo.db.host}:${nuxeo.db.port}/${nuxeo.db.name};selectMethod=cursor
nuxeo.db.driver=com.microsoft.sqlserver.jdbc.SQLServerDriver
nuxeo.db.xadatasource=com.microsoft.sqlserver.jdbc.SQLServerXADataSource

6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -2906,6 +2906,12 @@
<version>12.1.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>sqljdbc</artifactId>
<version>4.2.6420</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jmock</groupId>
<artifactId>jmock</artifactId>
Expand Down

0 comments on commit 6929cb2

Please sign in to comment.