0

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 127.0.0.1 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
    com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1049)
    com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3593)
    com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3525)
    com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1986)
    com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2140)
    com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2620)
    com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1890)
    com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3523)
    com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2386)

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):

Class.forName("com.mysql.jdbc.Driver").newInstance();
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!

AeroDroid
  • 101
  • 1

1 Answers1

1

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:

.getConnection("jdbc:mysql://localhost/schema?user=user_name&password=pass_word")

Hope it works.

Tristian
  • 155
  • 2
  • 11
  • Also I believe that this is more appropriate on the http://www.stackoverflow.com site, just a thought. – Tristian Jan 19 '11 at 07: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