JDBC to Mysql connectivity issue

Asked by Viki

 i have downloaded jdbc driver for mysql. and also installed mysql.
i can login to mysql normally through commandline but when i run my application it cannot connect to database.
the name of database i want to use is OS. user id is Vikram and password is viki.
the code i am running is

import java.sql.*;
public class DBCon{

private static Connection Db;
public static void main(String[] args) throws
String url="jdbc:mysql://localhost/OS";
String userID="vikram";
String password="viki";


the program runs till Class.forName... but when getConnection is called an exception occurs... the error is:

Exception in thread "main" 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
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1026)
   at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:956)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3558)
   at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3490)
   at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1959)
   at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2109)
   at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2642)
   at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1818)
   at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3544)
   at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2156)
   at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:781)
   at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:348)
   at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:284)
   at java.sql.DriverManager.getConnection(libgcj.so.10)
   at java.sql.DriverManager.getConnection(libgcj.so.10)
   at DBCon.main(DBCon.java:14)

i have no way outta this.!

Question information

English Edit question
Ubuntu mysql-dfsg-5.1 Edit question
No assignee Edit question
Last query:
Last reply:
Revision history for this message
David Hoeffer (d-hoeffer) said :

Which version of the JDBC driver is this? It doesn't seem the current one, as the line numbers don't match. Can you try and see if you get the same error with the most recent version?

Can you help with this problem?

Provide an answer of your own, or ask Viki for more information if necessary.

To post a message you must log in.