Skip to content

Commit

Permalink
Upgrade SQL Server and MySQL JDBC Driver versions
Browse files Browse the repository at this point in the history
  • Loading branch information
vladmihalcea committed Sep 23, 2022
1 parent 74eb526 commit 7bbd20c
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 43 deletions.
@@ -1,9 +1,9 @@
package com.vladmihalcea.hibernate.util.providers;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import com.mysql.cj.jdbc.MysqlDataSource;

import javax.sql.DataSource;
import java.util.Properties;
import java.sql.SQLException;

/**
* @author Vlad Mihalcea
Expand Down Expand Up @@ -81,15 +81,19 @@ protected String defaultJdbcUrl() {
}

protected DataSource newDataSource() {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());
dataSource.setRewriteBatchedStatements(rewriteBatchedStatements);
dataSource.setCachePrepStmts(cachePrepStmts);
dataSource.setUseServerPrepStmts(useServerPrepStmts);

return dataSource;
try {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());
dataSource.setRewriteBatchedStatements(rewriteBatchedStatements);
dataSource.setCachePrepStmts(cachePrepStmts);
dataSource.setUseServerPrepStmts(useServerPrepStmts);

return dataSource;
} catch (SQLException e) {
throw new IllegalStateException("The DataSource could not be instantiated!");
}
}

@Override
Expand Down
Expand Up @@ -18,7 +18,7 @@ public String hibernateDialect() {

@Override
public String defaultJdbcUrl() {
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;user=sa;password=adm1n";
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;encrypt=true;trustServerCertificate=true";
}

@Override
Expand Down
@@ -1,9 +1,9 @@
package com.vladmihalcea.hibernate.util.providers;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import com.mysql.cj.jdbc.MysqlDataSource;

import javax.sql.DataSource;
import java.util.Properties;
import java.sql.SQLException;

/**
* @author Vlad Mihalcea
Expand Down Expand Up @@ -81,15 +81,19 @@ protected String defaultJdbcUrl() {
}

protected DataSource newDataSource() {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());
dataSource.setRewriteBatchedStatements(rewriteBatchedStatements);
dataSource.setCachePrepStmts(cachePrepStmts);
dataSource.setUseServerPrepStmts(useServerPrepStmts);

return dataSource;
try {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());
dataSource.setRewriteBatchedStatements(rewriteBatchedStatements);
dataSource.setCachePrepStmts(cachePrepStmts);
dataSource.setUseServerPrepStmts(useServerPrepStmts);

return dataSource;
} catch (SQLException e) {
throw new IllegalStateException("The DataSource could not be instantiated!");
}
}

@Override
Expand Down
Expand Up @@ -18,7 +18,7 @@ public String hibernateDialect() {

@Override
public String defaultJdbcUrl() {
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;user=sa;password=adm1n";
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;encrypt=true;trustServerCertificate=true";
}

@Override
Expand Down
@@ -1,9 +1,9 @@
package com.vladmihalcea.hibernate.util.providers;

import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;
import com.mysql.cj.jdbc.MysqlDataSource;

import javax.sql.DataSource;
import java.util.Properties;
import java.sql.SQLException;

/**
* @author Vlad Mihalcea
Expand Down Expand Up @@ -81,15 +81,19 @@ protected String defaultJdbcUrl() {
}

protected DataSource newDataSource() {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());
dataSource.setRewriteBatchedStatements(rewriteBatchedStatements);
dataSource.setCachePrepStmts(cachePrepStmts);
dataSource.setUseServerPrepStmts(useServerPrepStmts);

return dataSource;
try {
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setURL(url());
dataSource.setUser(username());
dataSource.setPassword(password());
dataSource.setRewriteBatchedStatements(rewriteBatchedStatements);
dataSource.setCachePrepStmts(cachePrepStmts);
dataSource.setUseServerPrepStmts(useServerPrepStmts);

return dataSource;
} catch (SQLException e) {
throw new IllegalStateException("The DataSource could not be instantiated!");
}
}

@Override
Expand Down
Expand Up @@ -18,7 +18,7 @@ public String hibernateDialect() {

@Override
public String defaultJdbcUrl() {
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;user=sa;password=adm1n";
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;encrypt=true;trustServerCertificate=true";
}

@Override
Expand Down
Expand Up @@ -4,7 +4,6 @@

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Properties;

/**
* @author Vlad Mihalcea
Expand Down
Expand Up @@ -18,7 +18,7 @@ public String hibernateDialect() {

@Override
public String defaultJdbcUrl() {
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;user=sa;password=adm1n";
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;encrypt=true;trustServerCertificate=true";
}

@Override
Expand Down
Expand Up @@ -18,7 +18,7 @@ public String hibernateDialect() {

@Override
public String defaultJdbcUrl() {
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;user=sa;password=adm1n";
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;encrypt=true;trustServerCertificate=true";
}

@Override
Expand Down
Expand Up @@ -5,7 +5,6 @@

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.Properties;

/**
* @author Vlad Mihalcea
Expand Down
Expand Up @@ -19,7 +19,7 @@ public String hibernateDialect() {

@Override
public String defaultJdbcUrl() {
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;user=sa;password=adm1n";
return "jdbc:sqlserver://localhost;instance=SQLEXPRESS;databaseName=high_performance_java_persistence;encrypt=true;trustServerCertificate=true";
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -417,9 +417,9 @@
<hsqldb.version>2.2.8</hsqldb.version>
<h2.version>1.4.200</h2.version>
<postgresql.version>42.4.1</postgresql.version>
<mysql.version>5.1.47</mysql.version>
<mysql.version>8.0.30</mysql.version>
<oracle.version>21.5.0.0</oracle.version>
<mssql.version>6.4.0.jre8</mssql.version>
<mssql.version>11.2.1.jre8</mssql.version>

</properties>

Expand Down

0 comments on commit 7bbd20c

Please sign in to comment.