Problem with multiple DbManagers

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

Problem with multiple DbManagers

Postby JohnnyD » 26 Nov 2012, 12:23

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?
JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

Re: Problem with multiple DbManagers

Postby JohnnyD » 26 Nov 2012, 23:13

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.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Problem with multiple DbManagers

Postby rjgtav » 26 Nov 2012, 23:43

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.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
JohnnyD
Posts: 128
Joined: 29 Oct 2007, 22:13

Re: Problem with multiple DbManagers

Postby JohnnyD » 27 Nov 2012, 09:39

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?

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 27 guests