MS SQL SFS Unity3D Config.xml help needed

Need help with SmartFoxServer? You didn't find an answer in our documentation? Please, post your questions here!

Moderators: Lapo, Bax

User avatar
JalenBlade
Posts: 14
Joined: 11 Jun 2009, 15:35

MS SQL SFS Unity3D Config.xml help needed

Postby JalenBlade » 11 Jun 2009, 15:49

Hi everyone,
I'm new to SFS and Unity 3D and have some basic configuration issues to get through. Any help is greatly appreciated!

The docs contain info on how to connect to a MSAccess database and a MySQL database but no examples for a MS SQL database which is what I have. Does anyone know what to put in the following spots?

<Driver>sun.jdbc.odbc.JdbcOdbcDriver</Driver>
<ConnectionString>jdbc:odbc:sfsTest</ConnectionString>
<TestSQL><![CDATA[SELECT COUNT(*) FROM contacts]]></TestSQL>

Also, I'm looking for info on how to set up a sign-up screen and log-in screen once connected to the database. I'm loving this SFS and Unity 3D! Can't wait to get the basic structures in place so I can begin level design!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 11 Jun 2009, 19:02

<Driver>sun.jdbc.odbc.JdbcOdbcDriver</Driver>

This line specifies the Driver to use.
As specified in the documentation you can use the native ODBC driver if your DB supports it (MS SQL should definitely support ODBC) or use the native JDBC driver provided by the database vendor.

SmartFoxServer uses standard JDBC so further instructions on how to use the database specific driver are going to be found on your database website.

<ConnectionString>jdbc:odbc:sfsTest</ConnectionString>

This is the connection string.
If you use ODBC the last name (sfsTest) is the DSN (data source name), otherwise follow the docs provided with the JDBC driver.
<TestSQL><![CDATA[SELECT COUNT(*) FROM contacts]]></TestSQL

This is a simple test query that allows the Server to check if the database connection works and if it can execute queries on an existing table.

Also, I'm looking for info on how to set up a sign-up screen and log-in screen once connected to the database.

We provide login examples in our documentation. They are based on a Flash client but the server side part is identical no matter what client side technology you use, so you can follow those examples for the server side part.

See chapter 8 of the docs: http://www.smartfoxserver.com/docs/
Also check the Java Extension Cookbook: http://www.smartfoxserver.com/docs/docP ... okBook.htm

There are "Login recipes"
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
JalenBlade
Posts: 14
Joined: 11 Jun 2009, 15:35

Postby JalenBlade » 11 Jun 2009, 22:58

so then...

<Driver>odbc</Driver>
<ConnectionString>odbc:myDatabaseName</ConnectionString>
<TestSQL><![CDATA[SELECT COUNT(*) FROM mytableName]]></TestSQL>

should work?

EDIT: It doesn't...Ive tried a hundred combinations and consulted multiple web sites concerning connection strings for MS SQL but nothing I've tried works. I keep getting various errors mainly "Data source not found and no default driver specified."
My file looks like this at the moment.

<Driver>sun.jdbc.odbc.JdbcOdbcDriver</Driver>
<ConnectionString>jdbc:odbc:myDatabaseName</ConnectionString>
<UserName>myUsername</UserName>
<Password>myPassword</Password>
<TestSQL>select * from items</TestSQL>

I know it's something simple but grrrr....lol
If anyone else is using MS SQL and could copy/paste the segment from your config.xml file it would save me countless hours!

Thanks in advance for any help!
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Jun 2009, 05:45

Sorry but I have never used the MS database so I don't think I can help much here. Anyways setting up an ODBC connections is usually pretty simple

1) Setup the DSN on the DB machine
2) Connect to it

Have you done step 1?
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
mhdside
Posts: 236
Joined: 04 May 2008, 07:57
Location: Egypt
Contact:

Postby mhdside » 12 Jun 2009, 08:32

Jalen, I`m using an MS SQL Server db, I had some trouble like you but finally I got it to work, as Lapo said you should setupt a DSN for your db on the machine where the db exists, to do this:
Control Panel > Administrative tools > Data Sources (ODBC) > User DSN > add... > you should be able to move from there...
then in the config

Code: Select all

<DatabaseManager active="true">
   <Driver>sun.jdbc.odbc.JdbcOdbcDriver</Driver>
   <ConnectionString>jdbc:odbc:[your dsn name]</ConnectionString>
   <UserName>[db username]</UserName>
   <Password>[db password]</Password>
   <TestSQL><![CDATA[SELECT COUNT(*) FROM Users]]></TestSQL>
   <MaxActive>10</MaxActive>
   <MaxIdle>10</MaxIdle>
   <OnExhaustedPool>fail</OnExhaustedPool>
   <BlockTime>5000</BlockTime>
</DatabaseManager>


hope that helps.
Mahmoud Badri
Senior actionscript developer
http://www.el3ab.com
User avatar
JalenBlade
Posts: 14
Joined: 11 Jun 2009, 15:35

Postby JalenBlade » 12 Jun 2009, 12:26

Awesome! Worked beautifully and no more hair loss! I knew there had to be a simple step I was missing somewhere.
Does anyone have any experience setting up sign-up and login screens?
I'd be willing to pay someone to get that part out of the way so I can move on to creating the game.

Thanks gentlemen!
shive_1807
Posts: 1
Joined: 07 Jun 2021, 08:20

Re: MS SQL SFS Unity3D Config.xml help needed

Postby shive_1807 » 14 Jul 2021, 08:49

Hey I am integrating aws rds ms sql with smart fox server and has downloaded the jdbc jre file and place it in root/extension/__lib__ folder.
Now I have no idea about the driver class and the connection string for ms sql a little guidance will be highly appreciated.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: MS SQL SFS Unity3D Config.xml help needed

Postby Lapo » 15 Jul 2021, 14:56

Hi,
at this page:
https://docs.microsoft.com/en-us/sql/co ... a-database
they show how to build the connection string.

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SmartFoxServer 1.x Discussions and Help”

Who is online

Users browsing this forum: No registered users and 32 guests