aspose file tools*
The moose likes JDBC and the fly likes Mysql+Applet Connection Problem, attention pls. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Mysql+Applet Connection Problem, attention pls." Watch "Mysql+Applet Connection Problem, attention pls." New topic
Author

Mysql+Applet Connection Problem, attention pls.

erdem ozdemir
Greenhorn

Joined: Aug 09, 2005
Posts: 15
Hi. I am trying to connect my applet to a mysql server in my computer. But I have a problem.

Let me expand my problem:

here is my simple java code:


I executed this file in a different directory from www(localhost)so I used a java policy file including text below.


The output I get is:
Driver loaded.
Error: java.sql.SQLException: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.lang.NumberFormatException)
java.sql.SQLException: Cannot connect to MySQL server on localhost:3306. Is there a MySQL server running on the machine/port you are trying to connect to? (java.lang.NumberFormatException)
at com.mysql.jdbc.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.jdbc2.Connection.connectionInit(Unknown Source)
at com.mysql.jdbc.Driver.connect(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at DbConnectorForNet.ConnectDB(DbConnectorForNet.java:52)
at DbConnectorForNet.main(DbConnectorForNet.java:67)

Then I tested my mysql server with a php script, it works. After that I checked mysql config for skip-networking and i edited it like this:
; skip-networking

I am really in stack and I have no more idea why it does not work. I appreciate any useful idea, thanks in advance.

cheers

[ July 13, 2006: Message edited by: erdem ozdemir ]
Chad Clites
Ranch Hand

Joined: Aug 16, 2005
Posts: 134
Not sure if you are still having a problem with this or not, but I thought I would give an opinion anyway. Let me see if I follow what you are trying to do... you are sending an applet to someone's browser. That applet is trying to open a database on that remote computer. Is that what you really want to do? Or do you want the applet to open a database on the server?
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
If you are getting NumberFormatException, then remove localhost from there.

Use jdbc url like this...

jdbc:mysql:///mysql


Regards


Naseem


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
erdem ozdemir
Greenhorn

Joined: Aug 09, 2005
Posts: 15
Thanks for advices.

My aim was to connect db and applet which are on the same server.

thanks for interest java freaks
kamal kannan
Ranch Hand

Joined: Oct 06, 2006
Posts: 33
jdbc:mysql://localhost:3306/mysql

TRY
jdbc:mysql://localhost/mysql

BECAUSE 3306 IS MYSQL DEFAULT PORT YOU NEED NOT GIVE TO IT


SCJP 1.5 95% /SCWCD 1.5 93% /RHCE EL4 100% /WEBLOGIC 9.2 SYSTEM ADMINISTRATION 100% / Oracle Weblogic 10g Server Certified System Export 88%
 
 
subject: Mysql+Applet Connection Problem, attention pls.