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

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 » 17 Jul 2013, 08:20

Ok good. So, to summarize: by default you can configure on SFSDBManager from the AdminTool which will be created for you at startup and you will be able to access it from the Extension itself.

In your case you will also need other SFSDBManagers to be able to talk to the other databases.

Final suggestion, you might also want to create your own thread pool for DB work if you plan to have concurrent queries running on those DBs.
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! » 17 Jul 2013, 15:50

Groovy. Thanks! :D
patman
Posts: 5
Joined: 03 Dec 2020, 16:20

Re: The DBManager is NOT active in this Zone

Postby patman » 10 Dec 2020, 17:38

I know this is old but this was pretty relative to what I was experiencing. I know I am doing something wrong I just don't know what.

I followed https://smartfoxserver.com/blog/querying-the-database-and-sending-resultsets/ and http://tutorialtous.com/smartfoxserver/dbconfiguration.php#adminpanel

My client is a Unity Application.

I downloaded the server extensions source code for the People example and changed things slightly to

GetPeopleHandler.java

Code: Select all

package people;

import java.sql.SQLException;

import com.smartfoxserver.v2.db.IDBManager;
import com.smartfoxserver.v2.entities.User;
import com.smartfoxserver.v2.entities.data.ISFSArray;
import com.smartfoxserver.v2.entities.data.ISFSObject;
import com.smartfoxserver.v2.entities.data.SFSObject;
import com.smartfoxserver.v2.extensions.BaseClientRequestHandler;
import com.smartfoxserver.v2.extensions.ExtensionLogLevel;

public class GetPeopleHandler extends BaseClientRequestHandler
{
   @Override
   public void handleClientRequest(User sender, ISFSObject params)
   {
      IDBManager dbManager = getParentExtension().getParentZone().getDBManager();
      String sql = "SELECT * FROM people";
      
      try
        {
         // Obtain a result set
           ISFSArray res = dbManager.executeQuery(sql, new Object[] {}); // added the new Object[] parameter
          
           // Populate the response parameters
           ISFSObject response = new SFSObject();
           response.putSFSArray("people", res);
          
           // Send back to requester
           send("getPeople", response, sender);
        }
        catch (SQLException e)
        {
           trace(ExtensionLogLevel.WARN, "SQL Failed: " + e.toString());
        }
   }
}


PeopleExtension.java

Code: Select all

package people;

import com.smartfoxserver.v2.db.IDBManager;
import com.smartfoxserver.v2.entities.Zone;
import com.smartfoxserver.v2.extensions.SFSExtension;

public class PeopleExtension extends SFSExtension
{
   @Override
   public void init()
   {
      // ---- Added ----
      Zone zone = getParentZone();
      IDBManager dbManager = zone.getDBManager();
      dbManager.init(zone);
      // -- End Added --
      
      trace("People Example Started!");
      addRequestHandler("getPeople", GetPeopleHandler.class);
   }
   
   @Override
   public void destroy()
   {
      trace("People Example Stopped!");
       super.destroy();
   }
}


In my Unity client application I have logged an event listener to the "getPeople" response event that just writes the table to the console of the Unity Editor. The request is sent after I enter the lobby.

I then set things up in the zone configuration in the Admin Tool standalone the following are my settings

activate = true
driver class = com.mysql.jdbc.Driver
connection string = jdbc:mysql://127.0.0.1:3306/sfs2x
userName = root
password = ********
Test SQl = SELECT now()
max active = 10
max idle = 10
exhausted pool action = GROW

I then hit submit and reload. Then I restarted the server. Waited for it to start and ran the client application. After I connected and logged in the request fired but the database failed with this SQL exception:

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

What did I do wrong here? I feel like I followed all the steps, I keep rereading the docs and tried searching up an answer but nothing really worked for me.
patman
Posts: 5
Joined: 03 Dec 2020, 16:20

Re: The DBManager is NOT active in this Zone

Postby patman » 10 Dec 2020, 21:55

I think I figured out my problem, the connector jar was was 5.1 (or something like that) and my database was using 8.0.22 Updating the jar file in the extensions/__lib__ stopped the bug for me.
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 » 11 Dec 2020, 09:05

Thanks for the update
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X Questions”

Who is online

Users browsing this forum: No registered users and 46 guests