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.
The DBManager is NOT active in this Zone
Same Here
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:
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
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
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
I apologize it is my fault.
You must pass the owner Zone to the init() method of the SFSDBManager class.
like this:
where sfsDbManager is your SFSDBManager instance, and myZone is a reference to your current Zone.
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.
Re: The DBManager is NOT active in this Zone
I, unfortunately, have been stuck on this issue all day. Getting the exception message:
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.
Any ideas?
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?
Re: The DBManager is NOT active in this Zone
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.
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);
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);
Re: The DBManager is NOT active in this Zone
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.
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.
Re: The DBManager is NOT active in this Zone
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.
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.
Who is online
Users browsing this forum: No registered users and 42 guests