SFS 2X can't connect other database

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
nesv021
Posts: 5
Joined: 24 Apr 2018, 05:52

SFS 2X can't connect other database

Post 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);
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS 2X can't connect other database

Post by Lapo »

What error are you getting exactly?
Can you show use the stack trace?

Thanks
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
HTCraft
Posts: 27
Joined: 28 Jun 2018, 09:51
Location: Moscow, Russia
Contact:

Re: SFS 2X can't connect other database

Post by HTCraft »

Sometime connection needs define the time zone

Try

Code: Select all

cfg.connectionString = "jdbc:mysql://localhost:3306/****?useSSL=false&serverTimezone=UTC";
nesv021
Posts: 5
Joined: 24 Apr 2018, 05:52

Re: SFS 2X can't connect other database

Post 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.
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: SFS 2X can't connect other database

Post 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
Lapo
--
gotoAndPlay()
...addicted to flash games
Post Reply