Page 1 of 1

Problem with multiple DbManagers

Posted: 26 Nov 2012, 12:23
by JohnnyD
The docs say this is possible but I'm seeing problems trying to do it in Java. I create one DbManager GameDBManager in the XML config file like so:

Code: Select all

<ConnectionString>jdbc:mysql://----------------.com:3306/GameDB</ConnectionString>
I create the other, LoginDBManager in code, pointing to a DB on a totally different server (we share login between our game and an existing website):

Code: Select all

jdbc:mysql://--------------.com:3306/LoginDB
When I do:

Code: Select all

GameDBManager.executeQuery("select count(*) from users");
I get an error:
14:51:15.836 - [ SEVERE ] > DbManager error during query/result creation: select count(*) from users
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Table 'LoginDB.users' doesn't exist
So in summary, GameDBManager is running queries against LoginDB! How is this happening - is DbManager actually a singleton or something like that?

Re: Problem with multiple DbManagers

Posted: 26 Nov 2012, 23:13
by JohnnyD
As an update when I replace one of my calls to DbManager.getConnection() with a call to DriverManager.getConnection(...) using the exact same connection string, things appear to work.

Re: Problem with multiple DbManagers

Posted: 26 Nov 2012, 23:43
by rjgtav
Hi,

Have you tried creating both DBManager instances directly from the server-side extension, as explained here on the docs?
Maybe the system doesn't work well with one configured on the config.xml file and another one dynamically created.

Re: Problem with multiple DbManagers

Posted: 27 Nov 2012, 09:39
by JohnnyD
I didn't think to try that, but having the main DB configured in the config XML is the main reason I like DbManager ;) I guess I'll stick with using DataSource for the other DB - maybe if there's an internal bug list this could be recorded, but probably 1.x isn't still being developed?


I would be interested to know some more details how the SFS DbManager connection pooling is implemented though since it's closed-source. Is this documented, or could someone give a brief explanation so it could be compared against other pooling implementations?