Multiple DB Connections - Connection issue

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

Moderators: Lapo, Bax

andrew2110
Posts: 90
Joined: 28 May 2008, 13:36

Multiple DB Connections - Connection issue

Postby andrew2110 » 05 Oct 2018, 10:11

Hello!

I've followed the tutorial here:

https://smartfoxserver.com/blog/multipl ... nnections/

To create a second database connection to an external server, however it seems to be throwing this error message:

{HA3DZone}: java.sql.SQLException: The DBManager is NOT active in this Zone. SQL Query failed. Please activate it the DBManager from the AdminTool

The test SQL is something that shouldn't be possible to fail, here's the code to create the external DB connection:

Code: Select all

         
         DBConfig cfg = new DBConfig();
            cfg.active = true;
            cfg.driverName = "com.mysql.jdbc.Driver";
            cfg.connectionString = "jdbc:mysql://80.0.21.46/horseacademylts";
            cfg.userName = "root";
            cfg.password = "********";
            cfg.testSql = "SHOW TABLES";
            remoteDB = new SFSDBManager(cfg);
         


Is that error code going to be 100% accurate? What could reasons be that I could be seeing this error message? I am able to connect to this mysql database remotely via a PHP script on the main server so firewalls shouldn't be causing this issue. Any advice would be greatly appreciated.
andrew2110
Posts: 90
Joined: 28 May 2008, 13:36

Re: Multiple DB Connections - Connection issue

Postby andrew2110 » 05 Oct 2018, 10:30

I thought that changing it so it specified port number might be the reason it wasn't working but doing this hasn't helped:

cfg.connectionString = "jdbc:mysql://80.0.21.46:3306/horseacademylts";
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Multiple DB Connections - Connection issue

Postby Lapo » 05 Oct 2018, 14:35

Hi,
you need to keep a reference to your own remoteDB object for this to work.
If you invoke zone.getDBManager() it's a different object, not the one you have created manually.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 65 guests