Katalon 8.1.0: java.sql.Connection throws exception:Could not create connection to database server

I have the following code where on 7.8.2 version runs smoothly but on 8.1.0 throws exception:Could not create connection to database server.

Any ideas?

package dataBaseConnection
import java.sql.DriverManager
import java.sql.ResultSet
import java.sql.Statement
import com.kms.katalon.core.annotation.Keyword
import java.sql.Connection
import internal.GlobalVariable
public class DataBaseConnection {
	static host="host.net"
	static port='3333'
	static username='user'
static password= 'pass'


/**
 * Open and return a connection to database
 * @param dataFile absolute file path
 * @return an instance of java.sql.Connection
 */

//Establishing a connection to the DataBase
def connectDB(String dbName){
	java.sql.Connection connection
	//Load driver class for your specific database type
	String timezone ="?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"
	String conn = "jdbc:mysql://" + host + ":" + port + "/" + dbName+timezone

	if(connection != null && !connection.isClosed()){
		connection.close()
	}
	connection = DriverManager.getConnection(conn, username, password)
	return connection
}

//Closing the connection
def closeDatabaseConnection(Connection connection) {
	if(connection != null && !connection.isClosed()){
		connection.close()
	}
	connection = null

}

I made a quick search in Google with keyword “Could not create connection to database server”, then I found a web page

In there the following know-how was described. I am not sure if this is relevant to you


serverTimezone parameter was deprecated. you should not use it any longer.

visit

https://dev.mysql.com/doc/relnotes/connector-j/8.0/en/news-8-0-23.html

and search the page with “serverTimezone”

Hi friend,

As I known that 8.1.0 excluded mysql jar file, no longer support java package for mysql. You can download it manually the driver, then import to your project and try again.

Hope it will help.

Thank you very much you were right.

I downloaded and imported mysql-connector-java-8.0.26 into my project and worked fine.

Thank you kazurayam for the reply. The “serverTimezone=UTC” wasn’t the issue after all, according to @loc.nguyen 8.1.0 excluded mysql jar file and I needed to add it manually on my project.