Database Connection to SQL Server 2005

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

Moderators: Lapo, Bax

Post Reply
Fetz
Posts: 3
Joined: 18 Aug 2006, 17:27

Database Connection to SQL Server 2005

Post by Fetz »

Hello!
I am making a game but i'm having problem with the connection to the database!
I have Microsoft SQL Server 2005 JDBC Driver and i have put the sqljdbc.jar location
(.;C:\Program Files\Java\jre1.5.0_06\lib\ext\QTJava.zip;C:\Program Files\Microsoft SQL Server 2005 JDBC Driver\sqljdbc_1.0\enu\sqljdbc.jar)
in the classpath of the windows environment variables.
I have created the zone in the config.xml
<Zone name="game" uCountUpdate="true" customLogin="false" maxUsers="50">
<Rooms>
<Room name="Entrada" maxUsers="50" isPrivate="false" isTemp="false" autoJoin="true" uCountUpdate="true"/>
</Rooms>

<Extensions>
<extension name="bdacesso" className="bdacesso.as" type="script" />
</Extensions>

<DatabaseManager active="true">
<Driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</Driver>
<ConnectionString>jdbc:sqlserver://pc\SQLEXPRESS;databaseName=dbPokemonGame;user=pc\fetz;</ConnectionString>

<TestSQL><![CDATA[SELECT COUNT(*) FROM user]]></TestSQL>

<MaxActive>10</MaxActive>
<MaxIdle>10</MaxIdle>

<OnExhaustedPool>fail</OnExhaustedPool>
<BlockTime>5000</BlockTime>

</DatabaseManager>
</Zone>
but when i run the smartfoxserver gives me this error
java.lang.NullPointerException at it.gotoandplay.smartfoxserver.SmartFoxServer.setupZone(SmartFoxServer.java:1561)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.parser_Zones(ConfigReader.java:584)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.parser_Zones(ConfigReader.java:284)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:309)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:558)
Problems in config file: null
it.gotoandplay.smartfoxserver.exceptions.ConfigurationException
at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:308)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:309)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:558)

Errors found in configuration files.
Sorry for my english!
Could anyone help me please?
Thanks!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

The problem is that you have removed two mandatory tags of the database configuration:

<UserName> and <Password>

Please add them to the config and the problem will be solved
Lapo
--
gotoAndPlay()
...addicted to flash games
Fetz
Posts: 3
Joined: 18 Aug 2006, 17:27

Post by Fetz »

Thanks Lapo for your help but i did get another error message(sorry to be so annoying :(!

i copy the sqljdbc.jar to to my JRE lib/ext/ like is said in the docs
i create a user(teste) and give the permissions
i have tested the sql statement in the tag testsql
my local server name is pc\SQLEXPRESS

here is the error message
DB Manager Activated ( com.microsoft.sqlserver.jdbc.SQLServerDriver )
[severe] > DbManager could not retrive a connection. com.microsoft.sqlserver.jdbc.SQLServerException: The connection to the named istance has failed. Error: java.net.SocketTimeoutException: Receive time out.
it.gotoandplay.smartfoxserver.exceptions.DbManagerException: The Test Sql statement failde!

<DatabaseManager active="true">

<Driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</Driver>
<ConnectionString>jdbc:sqlserver://;serverName=pc\SQLEXPRESS;databaseName=dbPokemonGame</ConnectionString>

<UserName>teste</UserName>
<Password>teste1234</Password>

<TestSQL><![CDATA[SELECT COUNT(*) FROM dbo.[User]]]></TestSQL>

<MaxActive>10</MaxActive>
<MaxIdle>10</MaxIdle>

<OnExhaustedPool>fail</OnExhaustedPool>
<BlockTime>5000</BlockTime>

</DatabaseManager>
</Zone>
thank you again!
User avatar
Lapo
Site Admin
Posts: 23438
Joined: 21 Mar 2005, 09:50
Location: Italy

Post by Lapo »

This time the error is different, you have a SocketTimeoutException.
This means that your database is not reachable. There can be a number of reasons for this:

1. db server is not running
2. db server is firewalled
3. db server runs on the localhost only

There's something not entirely clear in your database connection:
jdbc:sqlserver://;serverName=pc\SQLEXPRESS;
How the "pc\SQLEXPRESS" address should be resolved? Are you sure you shouldn't use an IP address pointing to the database server?
Lapo
--
gotoAndPlay()
...addicted to flash games
Fetz
Posts: 3
Joined: 18 Aug 2006, 17:27

Post by Fetz »

Thanks Again Lapo for your big help!
Db was running but the problem was that the db was not reachable because was blocked the acess from TCP/IP
Now is running :)

The issue that you put about the connection i try and i can use the 2 ways in the connection (in my computer lol), the name of the server or the ip but maybe is better way to use the ip!
Post Reply