The DBManager is NOT active in this Zone

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

Moderators: Lapo, Bax

jtcui
Posts: 9
Joined: 03 Oct 2011, 02:35

The DBManager is NOT active in this Zone

Postby jtcui » 03 Oct 2011, 02:39

Try to access multiple database in the server side, so create DBConfig and get the DBManager instance by code.

Here is the code snippet:

public IDBManager getRuntimeDBManager() {
if (runtimeDBManager == null) {
DBConfig dbConfig = new DBConfig();
dbConfig.driverName = IDBConstants.DB_DRIVER_NAME;
dbConfig.connectionString = "jdbc:mysql://" + IDBConstants.DB_HOST + "/" + IDBConstants.DB_RUNTIME_DB;
dbConfig.userName = IDBConstants.DB_USERNAME;
dbConfig.password = IDBConstants.DB_PASSWORD;
dbConfig.active = true;
runtimeDBManager = new SFSDBManager(dbConfig);
}
return runtimeDBManager;
}

However, when access database by executeQuery using the DBManager instance, it throws an exception "The DBManager is NOT active in this Zone. Please active it by AdminTool".

I try to add the db config to the zone configuration by Admin Tool and make sure it's active. The same error happens. Not sure what the reason is. Appreciate for any answers. Thanks.
User avatar
Bax
Site Admin
Posts: 4608
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 03 Oct 2011, 07:16

This you restart SFS after activating the DBManager in the Zone?
And did you check the server-side logs for possible errors on Zone startup?
Paolo Bax
The SmartFoxServer Team
jtcui
Posts: 9
Joined: 03 Oct 2011, 02:35

Postby jtcui » 03 Oct 2011, 12:50

bax wrote:This you restart SFS after activating the DBManager in the Zone?
And did you check the server-side logs for possible errors on Zone startup?


restart the server and there is no error logs in the server side.
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 04 Oct 2011, 06:59

Please double check that the Zone is really configured the way we said and double check the logs.
Lapo
--
gotoAndPlay()
...addicted to flash games
jtcui
Posts: 9
Joined: 03 Oct 2011, 02:35

Postby jtcui » 04 Oct 2011, 11:40

Ok.I'll check it
maniatis1
Posts: 5
Joined: 04 Oct 2011, 21:23

Same Here

Postby maniatis1 » 04 Oct 2011, 21:33

I have the exact same problem. I have verified that my connection is active in the xml through the admin tool. The test connection IS working. I can succesefully query the DB that i have initially set in the admin tool. by doing the following:

Code: Select all

this.getParentExtension().getParentZone().getDBManager().executeQuery("SELECT * FROM Users");



However, this is where the problem comes in:
I want to make a new IDBManager so that I can connect to a different database dynamically while the game is running, by calling the following

Code: Select all

//the dbCfg param has been initialized above with the new connection to another database server.
IDBManager newManager = new SFSDBManager(dbCfg);


Now when I go to execute a query using the newManager, smart fox gives me the error: "The DBManager is NOT active in this Zone. Please active it by AdminTool".

Cannot figure out how to allow this to work. It seemed to work fine in smartfox Pro, but now that I am using smartfox2X it is not working out
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Oct 2011, 07:58

I apologize it is my fault.
You must pass the owner Zone to the init() method of the SFSDBManager class.

like this:

Code: Select all

sfsDbManager.init(myZone);

where sfsDbManager is your SFSDBManager instance, and myZone is a reference to your current Zone.
Lapo

--

gotoAndPlay()

...addicted to flash games
jtcui
Posts: 9
Joined: 03 Oct 2011, 02:35

Postby jtcui » 06 Oct 2011, 09:30

I tried the method init with parameter null, it works. Do I have to use the zone as the parameter?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 06 Oct 2011, 12:46

YES
Lapo

--

gotoAndPlay()

...addicted to flash games
maniatis1
Posts: 5
Joined: 04 Oct 2011, 21:23

works

Postby maniatis1 » 06 Oct 2011, 16:23

awsome thank you that worked perfectly
jtcui
Posts: 9
Joined: 03 Oct 2011, 02:35

Postby jtcui » 07 Oct 2011, 12:09

It works for me, too. Thanks.
bt!
Posts: 17
Joined: 21 Jun 2013, 00:05

Re: The DBManager is NOT active in this Zone

Postby bt! » 16 Jul 2013, 07:12

I, unfortunately, have been stuck on this issue all day. Getting the exception message:
The DBManager is NOT active in this Zone. SQL Query failed. Please activate it the DBManager from the AdminTool


In the AdminTool, I have the manager active and correctly configured for a local H2 database.
In the server-side code, however, I cannot get the extension to query a remote MySql database. (The test db is on Amazon at the moment, since we don't want to develop with live production data.)
The application has only one zone.

I am able to connect manually to the database from the same server I am running SFS2X v2.7 on.

I double-checked my settings & logs.
I downloaded a fresh mysql jdbc driver and tried it in various locations.
I tried hacking the XML file (this resulted in the server not starting as opposed to getting the error message).
I tried calling the SFSDBManager object's init() function with the zone reference.
I tried with and without testSqls.
Between each attempt, I kill & restart SFS.

Running out of ideas and search results as to where I am going wrong. :?

Code: Select all

public class MainDB
{
   static SFSDBManager mMainDB_RO = null;
   Zone theZone = myExtension.myZone;
   ...
   private void createDbConn()
   {
      DBConfig dbCfg = new DBConfig(); // Debug to see what default values are
      dbCfg.driverName = "com.mysql.jdbc.Driver";
      dbCfg.connectionString = "jdbc:mysql://xxx.amazonaws.com:3306/dbname"
      dbCfg.userName = "xxx"
      dbCfg.password = "xxx"
      dbCfg.maxActiveConnections = 15;
      dbCfg.maxIdleConnections = 15;
      dbCfg.exhaustedPoolAction = DBConfig.POOL_ACTION_FAIL;
      dbCfg.blockTime = 5000;
      dbCfg.testSql = "select 1;"

      mMainDB_RO = new SFSDBManager(dbCfg);
      mMainDB_RO.init(theZone);

      try
      {
         mMainDB_RO.executeQuery(dbCfg.testSql);
      }
      catch (Exception e)
      {
         System.out.println("SQL_pre_query failed: " + e.getMessage());
         mMainDB_RO = null;
      }
   }
}


Any ideas?
User avatar
Lapo
Site Admin
Posts: 22999
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: The DBManager is NOT active in this Zone

Postby Lapo » 16 Jul 2013, 07:53

I don't understand, if you have configured the DBManager in the AdminTool, why are you creating a DBManager manually? Just use the Zone's own DBManager.

This line in particular make no sense. The DBManager is already created by the server according to your settings but here you're manually injecting a new DBManager in the Zone.
mMainDB_RO.init(theZone);


You either use the Zone's DBManager via zone.getDBManager() or you use your own without injecting it into a Zone, which is done by calling init(null);
Lapo

--

gotoAndPlay()

...addicted to flash games
bt!
Posts: 17
Joined: 21 Jun 2013, 00:05

Re: The DBManager is NOT active in this Zone

Postby bt! » 16 Jul 2013, 19:24

Maybe I'm the one who doesn't understand. ;) I thought I needed an SFSDBManager instance for each database being accessed from the extension. One could be configured with AT, the others via server-side code.

In my setup:
* AT configures a local H2 database and it works fine.
* A similar instance of the given code accesses a local MySql database, and it seems to work fine.
* Two remote MySql databases get that exception thrown when accessed.

Is there a best way to manage access to these databases in the zone?

Also adding to the (my) confusion is that this is a SFS PRO 1.6 to 2.7 migration. In a lot of cases, I've tried to keep the code similar to the old deployment, but I've already come across instances in which I've had to toss the old code and rewrite.

For giggles, I also attempted calling init(null) on the non-zone-configured databases, and it didn't help.
bt!
Posts: 17
Joined: 21 Jun 2013, 00:05

Re: The DBManager is NOT active in this Zone

Postby bt! » 16 Jul 2013, 20:54

I think I solved it.

What I failed to recognise before now was the "active" field is something I have to set myself. On creating the other SFSDBManager instances, they defaulted to false. Manually setting them to true got rid of the error and I can now access data through it.

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 42 guests