Connecting to Database

Post here your questions about Actionscript and Java server side extensions development.

Moderators: Lapo, Bax

menachemt
Posts: 28
Joined: 22 Jun 2012, 13:56

Connecting to Database

Postby menachemt » 22 Jun 2012, 20:22

Hello. I have been having a problem with connecting to my database through the config file. Here is the code.
<Driver>org.gjt.mm.mysql.Driver</Driver>
<ConnectionString>jdbc:mysql://johnny.heliohost.org:3306/menachem_game</ConnectionString>


<UserName>menachem_game</UserName>
<Password>xxxxxxx</Password>

<TestSQL><![CDATA[SELECT username(*) FROM users]]></TestSQL>

The information on the database and all is correct. I have a row named username in a table called users in database menachem_game. I think the problem could be from the driver. I am using a mac and there is no jre file on mac so i dont really know where to play the driver. I placed it in a place but I don't think it was correct. The problem is that the testsql fails. Any help would be appreciated. Thanks in advance!
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Connecting to Database

Postby rjgtav » 22 Jun 2012, 23:28

Hello.
You can put the mysql connector driver inside [SFS1X Installation Folder]\Server\lib.
Can you try a simpler SQL statement like SELECT * FROM users?
If it still doesn't work, can you post the whole error you get on the console?
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
menachemt
Posts: 28
Joined: 22 Jun 2012, 13:56

Re: Connecting to Database

Postby menachemt » 24 Jun 2012, 02:20

Hello. Thank you but it still doesnt work. I have SFS PRO so I put it in the Server/lib file of the pro. Not sure if its the same as SFS 1x. Also I tried changing username(*) to * and it still doesnt work. I can't really copy the code here for you because every time Smartfoxserver gets an error, it justs shuts down automatically without me pressing a button so I can't copy the code. I managed to take a picture and it said that the testsql statement failed. How can I fix the shutting down problem so it doesnt shut down automatically so I can copy the code. Thanks in advance.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Connecting to Database

Postby rjgtav » 24 Jun 2012, 15:24

Yes, SFS Pro is SFS1x (the older version).
If you want SFS not to close the window right after it gets an error, you can manually start the server by running the start.bat from the command prompt (start command line, navigate to the Server folder and then open the start.bat file)
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
menachemt
Posts: 28
Joined: 22 Jun 2012, 13:56

Re: Connecting to Database

Postby menachemt » 24 Jun 2012, 16:23

Hello. I am sorry, but I am running a mac, and all I have is the start.sh file, not start.bat file. Can I start it manually with the start.sh file? If not, how do I locate the start.bat file. Thanks in advance.

Edit: I managed to copy the error, although the server still shuts down automatically. I hope this can help you help me. If you need any more information just ask. Thanks in advance.

|::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::|
| |
| ...::: SmartFoxServer :::... |
| Multiplayer Socket Server |
| version 1.6.6 |
| --- |
| (c) 2004 - 2009 gotoAndPlay() |
| www.smartfoxserver.com |
| www.gotoandplay.it |
| |
|::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::|

::::::::::: { BlueBox INITED } ::::::::::::
: :
: Version 1.0.5 -- (c) 2008 gotoAndPlay() :
: :
:::::::::::::::::::::::::::::::::::::::::::
14:33:13.721 - [ INFO ] > Starting h2 engine...


--- [ System Info ] ------------------------------------------

System CPU(s): 2
VM Max memory: 129 MB

os.name: Mac OS X
os.arch: x86_64
os.version: 10.6.8
java.version: 1.6.0_33
java.vendor: Apple Inc.
java.vendor.url: http://www.apple.com/
java.vm.specification.version: 1.0
java.vm.version: 20.8-b03-424
java.vm.vendor: Apple Inc.
java.vm.name: Java HotSpot(TM) 64-Bit Server VM


--- [ Network Cards ] -----------------------------------------

Card:en1
-> fe80:0:0:0:7aca:39ff:feba:de83%5
-> 192.168.1.104
Card:lo0
-> fe80:0:0:0:0:0:0:1%1
-> 0:0:0:0:0:0:0:1
-> 127.0.0.1


--- [ Licence Loaded ] ------------------------------------

License Type -> PRO
License Owner -> --== Free Demo Licence ==--
Max. Clients -> 20
BlueBox Type -> Demo Version

--- [ Zones & Rooms ] -------------------------------------

14:33:15.127 - [ INFO ] > Default Buddy List Persister <INITED>
Zone: simpleChat

The Hall (id: 1, max: 50, pass:N)
The Kitchen (id: 2, max: 50, pass:N)
The Garden (id: 3, max: 50, pass:N)
The Bathroom (id: 4, max: 50, pass:N)
The Garage (id: 5, max: 50, pass:N)
The Living Room (id: 6, max: 50, pass:Y)
14:33:15.682 - [ INFO ] > Zone Extension [ json ] created, for zone:simpleChat
[jsonSample.as]: JSON Example initialized

14:33:15.698 - [ INFO ] > Default Buddy List Persister <INITED>
DB Manager Activated ( org.gjt.mm.mysql.Driver )
Can't load db driver: org.gjt.mm.mysql.Driver
14:33:15.700 - [ SEVERE ] > DbManager could not retrive a connection. java.sql.SQLException: Configuration file not found
it.gotoandplay.smartfoxserver.exceptions.DbManagerException: The Test SQL statement failed! Please check your configuration.
at it.gotoandplay.smartfoxserver.SmartFoxServer.setupZone(SmartFoxServer.java:1843)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.parse_Zones(ConfigReader.java:806)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:174)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:339)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:607)
Problems in config file: The Test SQL statement failed! Please check your configuration.
it.gotoandplay.smartfoxserver.exceptions.ConfigurationException: The Test SQL statement failed! Please check your configuration.
at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:199)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:339)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:607)

Errors found in configuration files.
Unable to start the server.


Shutting down server...
Last edited by menachemt on 24 Jun 2012, 18:41, edited 1 time in total.
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Connecting to Database

Postby rjgtav » 24 Jun 2012, 18:19

Oh, yes start manually the file you usually use for starting the server, but by using the command prompt.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
menachemt
Posts: 28
Joined: 22 Jun 2012, 13:56

Re: Connecting to Database

Postby menachemt » 24 Jun 2012, 19:29

Its ok. I managed to copy the code. Can you find the problem? Thanks
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Connecting to Database

Postby rjgtav » 24 Jun 2012, 22:36

Yes, the server still shuts down but now we can see what exactly causes that.
It says that what's causing the shutdown is because the server can't find the driver, which means, it isn't being loaded by SFS on startup. Are you sure that you have added it to the SFS Pro\Server\lib folder?
Oh, and don't forget to add it also to the start.sh file, you can add it near the h2.jar.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
menachemt
Posts: 28
Joined: 22 Jun 2012, 13:56

Re: Connecting to Database

Postby menachemt » 24 Jun 2012, 22:51

I added the mysql connector jar file and the org file in the SFS PRO/Server/lib file and in SFS PRO/Server, which is next to start.sh. I get this error now. This error is the same error as I got before. Is there another thing I can try? What can be a possible reason this doesn't work? Thanks

|::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::|
| |
| ...::: SmartFoxServer :::... |
| Multiplayer Socket Server |
| version 1.6.6 |
| --- |
| (c) 2004 - 2009 gotoAndPlay() |
| http://www.smartfoxserver.com |
| http://www.gotoandplay.it |
| |
|::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::|

::::::::::: { BlueBox INITED } ::::::::::::
: :
: Version 1.0.5 -- (c) 2008 gotoAndPlay() :
: :
:::::::::::::::::::::::::::::::::::::::::::
18:45:06.496 - [ INFO ] > Starting h2 engine...


--- [ System Info ] ------------------------------------------

System CPU(s): 2
VM Max memory: 129 MB

os.name: Mac OS X
os.arch: x86_64
os.version: 10.6.8
java.version: 1.6.0_33
java.vendor: Apple Inc.
java.vendor.url: http://www.apple.com/
java.vm.specification.version: 1.0
java.vm.version: 20.8-b03-424
java.vm.vendor: Apple Inc.
java.vm.name: Java HotSpot(TM) 64-Bit Server VM


--- [ Network Cards ] -----------------------------------------

Card:en1
-> fe80:0:0:0:7aca:39ff:feba:de83%5
-> 192.168.1.104
Card:lo0
-> fe80:0:0:0:0:0:0:1%1
-> 0:0:0:0:0:0:0:1
-> 127.0.0.1


--- [ Licence Loaded ] ------------------------------------

License Type -> PRO
License Owner -> --== Free Demo Licence ==--
Max. Clients -> 20
BlueBox Type -> Demo Version

--- [ Zones & Rooms ] -------------------------------------

18:45:07.811 - [ INFO ] > Default Buddy List Persister <INITED>
Zone: simpleChat

The Hall (id: 1, max: 50, pass:N)
The Kitchen (id: 2, max: 50, pass:N)
The Garden (id: 3, max: 50, pass:N)
The Bathroom (id: 4, max: 50, pass:N)
The Garage (id: 5, max: 50, pass:N)
The Living Room (id: 6, max: 50, pass:Y)
18:45:08.295 - [ INFO ] > Zone Extension [ json ] created, for zone:simpleChat
[jsonSample.as]: JSON Example initialized

18:45:08.303 - [ INFO ] > Default Buddy List Persister <INITED>
DB Manager Activated ( org.gjt.mm.mysql.Driver )
Can't load db driver: org.gjt.mm.mysql.Driver
18:45:08.304 - [ SEVERE ] > DbManager could not retrive a connection. java.sql.SQLException: Configuration file not found
it.gotoandplay.smartfoxserver.exceptions.DbManagerException: The Test SQL statement failed! Please check your configuration.
at it.gotoandplay.smartfoxserver.SmartFoxServer.setupZone(SmartFoxServer.java:1843)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.parse_Zones(ConfigReader.java:806)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:174)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:339)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:607)
Problems in config file: The Test SQL statement failed! Please check your configuration.
it.gotoandplay.smartfoxserver.exceptions.ConfigurationException: The Test SQL statement failed! Please check your configuration.
at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigReader.java:199)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFoxServer.java:339)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:607)

Errors found in configuration files.
Unable to start the server.


Shutting down server...
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Connecting to Database

Postby rjgtav » 24 Jun 2012, 23:22

You have to edit the start.sh file and add it there. For example, in the start.bat file it has:

@echo off
"..\jre\bin\java.exe" -server -cp "./;./sfsExtensions/;lib/activation.jar;lib/commons-beanutils.jar;lib/commons-collections-3.2.jar;lib/commons-dbcp-1.2.1.jar;lib/commons-lang-2.3.jar;lib/commons-logging-1.1.jar;lib/commons-pool-1.2.jar;lib/concurrent.jar;lib/ezmorph-1.0.3.jar;lib/h2.jar;..."

As you can see, the h2.jar file is added there. You have to do the same for te mysql connector.

As an alternative, you can also add it to the [SFS Pro]\jre\lib\ext folder, and it will automatically be loaded by SFS and you don't need to mess with the start.sh file. (sorry but I don't work with SFS Pro for a while and there are some things that I no longer remember).

Anyway, don't forget to check the documentation at http://www.smartfoxserver.com/docs/1x/, as it explains pratically everything regarding SFS Pro, including this problem ;)
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
menachemt
Posts: 28
Joined: 22 Jun 2012, 13:56

Re: Connecting to Database

Postby menachemt » 24 Jun 2012, 23:29

Thank you so much! It finally works! :D This problem would've been solved a long time ago if I had a jre foler. :/ Well, thanks for your time. You are the best! BTW, does this also fix my TestSQL problem? SFS PRO loads fine, I was just curious if the driver was also the cause of the TestSQL error?
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: Connecting to Database

Postby rjgtav » 24 Jun 2012, 23:33

Yes, probably it was. If it loads fine is because it also runs the Test SQL statement correctly.
The "The Test SQL statement failed!" error informs us that the TestSQL statement really failed, but we always have to check the rest of the logs, because some other errors may have happened before that one.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
menachemt
Posts: 28
Joined: 22 Jun 2012, 13:56

Re: Connecting to Database

Postby menachemt » 24 Jun 2012, 23:36

Ok. Thanks again. :D

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 55 guests