Page 1 of 1
SFS 2X can't connect other database
Posted: 11 Dec 2019, 08:39
by nesv021
I have 2 database in MySQL Workbench:
- db_test1 connect o Zone1
- db_test2 connect to Zone2
I can connect db_test1 but I can't db_test2
I tried turn off Zone1 and turn off connection for db_test1, but I still can't connect to db_test2.
Please help me.
This is my code:
DBConfig cfg = new DBConfig();
cfg.active = true;
cfg.driverName = "com.mysql.jdbc.Driver";
cfg.connectionString = "jdbc:mysql://localhost:3306/****?useSSL=false";
cfg.userName = "root";
cfg.password = "12345678";
cfg.testSql = "SELECT * FROM user";
cfg.maxActiveConnections = 15;
cfg.maxIdleConnections = 15;
dbm = new SFSDBManager(cfg);
dbm.init(this);
Re: SFS 2X can't connect other database
Posted: 11 Dec 2019, 09:43
by Lapo
What error are you getting exactly?
Can you show use the stack trace?
Thanks
Re: SFS 2X can't connect other database
Posted: 11 Dec 2019, 11:56
by HTCraft
Sometime connection needs define the time zone
Try
Code: Select all
cfg.connectionString = "jdbc:mysql://localhost:3306/****?useSSL=false&serverTimezone=UTC";
Re: SFS 2X can't connect other database
Posted: 12 Dec 2019, 01:37
by nesv021
Lapo wrote:What error are you getting exactly?
Can you show use the stack trace?
Thanks
I have many database in MySql Workbench, but I only can connect one database, all the other I can't connect them. I only need to change the database name in the connection string and the Test query to be able to connect to the db_test1 database.
I wonder sfs2x be cached and can only connect 1 database.
This is error log I received:
ERROR [main] db.SFSDBManager - java.sql.SQLNonTransientConnectionException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.sql.SQLNonTransientConnectionException
Message: Cannot load connection class because of underlying exception: com.mysql.cj.exceptions.WrongArgumentException: Malformed database URL, failed to parse the main URL sections.
Description: The DBManager Test SQL failed: SELECT * FROM user
Please double check your SQL code and make sure that Database server is running.
Re: SFS 2X can't connect other database
Posted: 12 Dec 2019, 10:14
by Lapo
Never heard of this error before (
SQLNonTransientConnectionException )
What version of MySQL are you using? Also what version of the mysql-connector-java?
In your code you have this:
Code: Select all
...
...
dbm = new SFSDBManager(cfg);
dbm.init(this);
I am not sure the last line is correct. What is "
this"?
Normally you need to pass the reference to the current Zone, but
this references the Extension itself.
I think you should use:
Code: Select all
dbm = new SFSDBManager(cfg);
dbm.init(getParentZone());
Cheers