Hi Lapo,
My client app has to connect to two databases.
One is remote and another is local.
My situation is when client app is started ,
it has to send user's name and pass to a remote database to check
if this user is a registered one.
If this user is already registered then the server extension auto
login this user .
And the user's records during playing are recorded into local database where
sfs is runnig.
The remote SQL server I used is SQL2000 running on win2003
and the local server which sfs is running is win2003 too.
The version of sfs is pro 1.4b3.
Any suggestion?
connecting to two database?
Hi,
at the moment each zone can setup only one connection to a database and w e usually recommend to use only one whenever possible. This helps in saving resources and keeping your application simpler.
By using a Java extension it would be pretty simple to access other databases. I will experiment a little with the current AS 1.0 framework and see if it's possible to do it in Actionscript too.
I will let you know
at the moment each zone can setup only one connection to a database and w e usually recommend to use only one whenever possible. This helps in saving resources and keeping your application simpler.
By using a Java extension it would be pretty simple to access other databases. I will experiment a little with the current AS 1.0 framework and see if it's possible to do it in Actionscript too.
I will let you know
Okay, I've inspected the framework and it's definitely easy to setup new connections. Here's how to do it.
You can access an object called __db.DbManager which will create a new connection to a new database.
Here's an example of how to setup a new connection:
As you can see the constructor takes the same exact parameters that you would normally specify in the <DatabaseManager> block of the server config file.
You can find more info about those paramaters here > http://www.smartfoxserver.com/docs/docP ... ection.htm
Finally, make sure to destroy the dbase2 variable in the destroy() method of your extension to release the resource, once it's not needed.
Hope it helps
You can access an object called __db.DbManager which will create a new connection to a new database.
Here's an example of how to setup a new connection:
Code: Select all
function testDB()
{
var driverName = "org.gjt.mm.mysql.Driver"
var connString = "jdbc:mysql://localhost:3306/myDatabase"
var usrName = "login"
var pword = "password"
var connName = "myDbConnection"
var maxActive = 10
var maxIdle = 10
var exhaustedAction = "fail"
var blockTime = 5000
dbase2 = new __db.DbManager( driverName,
connString,
usrName,
pword,
connName,
maxActive,
maxIdle,
exhaustedAction,
blockTime
)
var sql = "SELECT nick,pass FROM users ORDER BY nick"
var queryRes = dbase2.executeQuery(sql)
// etc... etc...
}
As you can see the constructor takes the same exact parameters that you would normally specify in the <DatabaseManager> block of the server config file.
You can find more info about those paramaters here > http://www.smartfoxserver.com/docs/docP ... ection.htm
Finally, make sure to destroy the dbase2 variable in the destroy() method of your extension to release the resource, once it's not needed.
Hope it helps
Return to “Server Side Extension Development”
Who is online
Users browsing this forum: No registered users and 46 guests