So I'm setting up my new server after my old one had died of a server failure. The only boulder I've hit is the JDBC set up. My server runs a Java program that had originally worked fine with the old server. I'll cut to the chase and show you what the problem is... Here is the stack trace when I try to connect using as well as localhost:

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '????????????????' at line 1

Quite vague isn't it?

This is the code that I use to connect to the server (which has been working fine on my old server):

Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/schema?user=user_name&password=pass_word");

Here is some information about my server: Server is running Debian Squeeze, MySQL is set up fine because phpMyAdmin works perfectly, Java version 1.5.0, JDBC Connector/J version 5.1.14, CLASSPATH has been set to the correct directory, ports properly forwarded 3306.

My last resorts are permissions which I'm not exactly sure how to fix for this criteria. So, for anyone that got a Java server connected to JDBC correctly, what do you think I'm missing? Like I mentioned, this Java server HAS worked on my old server (but that was running Debian Lenny). Thank you!


As the exception shows the error is in the SQL syntax, probably in the JDBC Url, if you read the documentation you can see that when the port isn't specifed the colon sould also be ommited, try this:


Hope it works.

  • Also I believe that this is more appropriate on the stackoverflow.com site, just a thought. – Tristian Jan 19 '11 at 7:18
  • Sorry about that, I wasn't sure whether StackOverflow was appropriate or not. – AeroDroid Jan 19 '11 at 23:23
  • Actually, it was my mistake that I forgot to mention that the port was specified in this address. I just edited the post, but still doesn't work even when I omit the port entirely. – AeroDroid Jan 19 '11 at 23:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.