MySql Connection Confusion, Basic Questions

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

Moderators: Lapo, Bax

Shawn5151
Posts: 26
Joined: 16 Feb 2009, 09:03

MySql Connection Confusion, Basic Questions

Postby Shawn5151 » 30 Mar 2009, 04:34

Can't seem to connect to my remote mysql db. Here's my config:

<Driver>com.mysql.jdbc.Driver</Driver>
<ConnectionString>jdbc:mysql://94.74.31.145/mytest</ConnectionString>

<UserName>blahblah</UserName>
<Password>xxxxxx</Password>


I get a "Can't load db driver error... [SEVERE] DBmanger could not retrieve a connection..."

I'm unclear on just a couple of points. Sorry if these are very basic questions. Do I need to download and install a mysql driver? Isn't that what the <Driver> connection tag above is for? I'm running on windows vista. Which folder would I put the mysql driver into if I need to download one? My database is on another server. Do you know if my connection string is in the correct format? The IP address I've put in is simply what phpmyadmin says at the top is the Server address for my db. Do I need to add a port # like :3306 or anything else? The name of my db is mytest, but apparently it's not getting past the driver part.

Any feedback much appreciated.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 31 Mar 2009, 05:33

By default MySQL only allows connections from the localhost.
If your SFS and MySQL are running on two different IP addresses you will need to authorize the access from the MySQL side.

p.s. = btw your driver is working okay, otherwise you would get another type of error.
Lapo
--
gotoAndPlay()
...addicted to flash games
Shawn5151
Posts: 26
Joined: 16 Feb 2009, 09:03

Postby Shawn5151 » 31 Mar 2009, 12:20

Thanks Lapo. I never downloaded a mysql driver though. What folder do I put that in? Do I need that in the above setup? I'm using 1.6.5 on vista, thanks.
Shawn5151
Posts: 26
Joined: 16 Feb 2009, 09:03

Postby Shawn5151 » 01 Apr 2009, 02:46

Sorry Lapo but I cannot get this working even though I have allowed remote access on my db server. I have searched here for similar posts and this is the closest one, but there is no answer there:

viewtopic.php?t=4293&highlight=load++driver

Here is my config:

<DatabaseManager active="true">
<Driver>org.gjt.mm.mysql.Driver</Driver> <ConnectionString>jdbc:mysql://97.74.31.9:3306/testdb</ConnectionString> <UserName>blahblah</UserName> <Password>xxxxxx</Password>
<TestSQL><![CDATA[SELECT COUNT(*) FROM table1]]></TestSQL>


I keep getting this error:

DB Manager Activated <org. gjt.mm.mysql.Driver>
Can't load db driver: org.gjt.mm.mysql.Driver
[SEVERE] > DBManager could not retrieve a connection. java.sql.SQLException: Configuration file not found

Any ideas? Thank you.
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 01 Apr 2009, 06:17

It seems your mysql driver is not seen in the classpath. Have you followed the instructions found here?
http://www.smartfoxserver.com/docs/docP ... ection.htm

You should simply copy the .jar file to {sfs-install-dir}/jre/lib/ext folder
Lapo

--

gotoAndPlay()

...addicted to flash games
duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 18 Apr 2009, 02:00

I'm having similar problems. Both SFS and mysql are on the same computer. I copied the latest JDBC for mysql, as per the instructions, and it still doesn't work. SFS even says it's processing that jar file!

Code: Select all

*sys-package-mgr*: processing new jar, 'C:\Program Files\SmartFoxServerPRO_1.6.2
\jre\lib\ext\mysql-connector-java-3.1.14-bin.jar'


But then goes on to say that it can't load the driver!

Code: Select all

Can't load db driver: org.gjt.mm.mysql


Here's a copy/paste of what im getting on server start:
http://dukecg.net/ohmy.txt
orthiac
Posts: 115
Joined: 25 Jun 2008, 10:03
Location: Massachusetts, USA

Postby orthiac » 18 Apr 2009, 09:07

Hey duke,

You may need to change the Driver in your config.xml to your current driver.
You may want to check out this post for some hints.
http://www.smartfoxserver.com/forums/viewtopic.php?p=15260#15260

Hope it helps,
- Mike
duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 18 Apr 2009, 13:03

orthiac wrote:Hey duke,

You may need to change the Driver in your config.xml to your current driver.
You may want to check out this post for some hints.
http://www.smartfoxserver.com/forums/viewtopic.php?p=15260#15260

Hope it helps,
- Mike


Thank you sir - that worked! I was still using the old driver name.
orthiac
Posts: 115
Joined: 25 Jun 2008, 10:03
Location: Massachusetts, USA

Postby orthiac » 18 Apr 2009, 17:23

duke wrote:Thank you sir - that worked! I was still using the old driver name.

NP. Sometimes we get lucky. :wink:
User avatar
Ross Przybylski
Posts: 70
Joined: 24 Jan 2008, 03:56
Contact:

Postby Ross Przybylski » 18 Jun 2009, 19:43

I'm having some trouble connecting to my MySQL forums database that's hosted remotely via Godaddy.com. Here's the error I'm getting:

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

DB Manager Activated ( org.gjt.mm.mysql.Driver )
16:07:23.860 - [ SEVERE ] > DbManager could not retrive a connection. com.mysql.
jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
it.gotoandplay.smartfoxserver.exceptions.DbManagerException: The Test SQL statem
ent failed! Please check your configuration.
at it.gotoandplay.smartfoxserver.SmartFoxServer.setupZone(SmartFoxServer
.java:1843)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.parse_Zones(ConfigRead
er.java:806)
at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigR
eader.java:174)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFo
xServer.java:339)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:
607)
Problems in config file: The Test SQL statement failed! Please check your config
uration.
it.gotoandplay.smartfoxserver.exceptions.ConfigurationException: The Test SQL st
atement failed! Please check your configuration.
at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigR
eader.java:199)
at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFo
xServer.java:339)
at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:
607)

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

I've got mysql-connector-java-5.1.7-bin.jar copied to my SmartFoxServerPRO_1.6.6\jre\lib\ext folder. Here's what my database configuration looks like:

Code: Select all

<DatabaseManager active="true">
   
   <Driver>org.gjt.mm.mysql.Driver</Driver>
   <ConnectionString>jdbc:mysql://her0913310164613.db.4054273.hostedresource.com</ConnectionString>
   
   <UserName>********</UserName>
   <Password>********</Password>
   
   <TestSQL><![CDATA[SELECT COUNT(*) FROM smf_members]]></TestSQL>
   
   <MaxActive>10</MaxActive>
   <MaxIdle>10</MaxIdle>
   
   <OnExhaustedPool>fail</OnExhaustedPool>
   <BlockTime>5000</BlockTime>
      
</DatabaseManager>



Thanks in advance for the help!
orthiac
Posts: 115
Joined: 25 Jun 2008, 10:03
Location: Massachusetts, USA

Postby orthiac » 18 Jun 2009, 22:36

I'm not sure about the connection string, but you may want to try the new driver name (com.mysql.jdbc.Driver) instead of org.gjt.mm.mysql.Driver.

- Mike
User avatar
Ross Przybylski
Posts: 70
Joined: 24 Jan 2008, 03:56
Contact:

Postby Ross Przybylski » 19 Jun 2009, 00:40

Thanks orthiac. I tried your suggestion, but got similar results (see below). Any other ideas?

Code: Select all

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

        DB Manager Activated ( com.mysql.jdbc.Driver )
21:03:15.091 - [ SEVERE ] > DbManager could not retrive a connection. com.mysql.
jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure

Last packet sent to the server was 0 ms ago.
it.gotoandplay.smartfoxserver.exceptions.DbManagerException: The Test SQL statem
ent failed! Please check your configuration.
        at it.gotoandplay.smartfoxserver.SmartFoxServer.setupZone(SmartFoxServer
.java:1843)
        at it.gotoandplay.smartfoxserver.lib.ConfigReader.parse_Zones(ConfigRead
er.java:806)
        at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigR
eader.java:174)
        at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFo
xServer.java:339)
        at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:
607)
Problems in config file: The Test SQL statement failed! Please check your config
uration.
it.gotoandplay.smartfoxserver.exceptions.ConfigurationException: The Test SQL st
atement failed! Please check your configuration.
        at it.gotoandplay.smartfoxserver.lib.ConfigReader.readZoneConfig(ConfigR
eader.java:199)
        at it.gotoandplay.smartfoxserver.SmartFoxServer.initServerSocket(SmartFo
xServer.java:339)
        at it.gotoandplay.smartfoxserver.SmartFoxServer.run(SmartFoxServer.java:
607)

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


Shutting down server...
orthiac
Posts: 115
Joined: 25 Jun 2008, 10:03
Location: Massachusetts, USA

Postby orthiac » 19 Jun 2009, 09:00

Sometime we're lucky, sometimes we work. :?

Not sure. It may take some additional information to find the answer.

Are you running the SFServer remotely or locally to your hosting account?
- You may need additional settings on your hosted site to access it remotely.

Can you connect to it (the same way) using some other method?
= SQL Developer is a free application to help work with db's.

Have you checked with GoDaddy or Google?
= GoDaddy Help Center Google


- Mike
User avatar
Lapo
Site Admin
Posts: 23009
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 19 Jun 2009, 11:06

Instead of using the server name here:

Code: Select all

<ConnectionString>jdbc:mysql://her0913310164613.db.4054273.hostedresource.com</ConnectionString>

try using the IP address of your MySQL server.
Also make sure that your MySQL server is configured to accept client connections from the outside world. By default MySQL listens only on 127.0.0.1 (localhost)
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
Ross Przybylski
Posts: 70
Joined: 24 Jan 2008, 03:56
Contact:

Postby Ross Przybylski » 19 Jun 2009, 16:21

Thanks everyone for your help. As it turns out, it was indeed the remote connectivity of the MySQL server that was causing issue. For all future forum readers, if you use Godaddy hosting for your MySQL databases, you need to ensure the "remote" option is enabled at the time you create the database because remote databases are stored on a different server than their local ones. If you need to change this setting at a later time, you will need to backup the old database, create a new database with remote on, and then restore the new database with the old one's backup file.

So- now that I've got database connection working, I have a new problem! I'm trying to insert a new record into a DB table and the server is jbdc driver is rejecting the command because certain values don't have default values- namingly, values with text datatypes that are set to non-null. (FYI- The database I am trying to add values to was created by my Simple Machines Forum). The strange thing is, I can use phpAdmin and the same SQL command that didn't work with the jbdc driver in SFS works fine in phpMyAdmin. All of the cells with text datatypes simply show as being empty (just like when the forum adds records). Does anyone know why the jbdc behavior would be different? Any recommended solutions?

Return to “Server Side Extension Development”

Who is online

Users browsing this forum: No registered users and 31 guests