Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

share|improve this question

1 Answer 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.

share|improve this answer
    
Also I believe that this is more appropriate on the stackoverflow.com site, just a thought. –  Triztian 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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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