Results 1 to 3 of 3
  1. #1
    habibiwalla is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default You have an error in your SQL syntax; check the manual that corresponds to your MySQL

    Hi All,

    I have installed ubuntu 9 and downloaded mysql-server, JDBC connector and Eclipse 3.2 via synaptic Manager. The versions I have

    mysql-server 5.1 (5.1.31 ubuntu 2)
    mysqlclient 5.1 (5.1.31 ubuntu 2)
    libmysql-java 5.1.6 JDBC (mysql-connector-java-5.1.6-bin.jar)
    ubuntu 9

    I was testing a simple code to check if a connection with a test database is established or not on mysql server but I keep receiving this error:

    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

    I am using the username root and the password that I put during mysql installation. The same code is working fine on my WIndows XP installation (mysql 5.1 and jdbc connector 5.1) with no errors.

    Why am I getting this problem ? I am not running any SQL query in the code!!!

    Is there a version conflict with current ubuntu packages?

    The whole code is listed below from a sun jdbc tutorial.


    import java.sql.Connection;
    import java.sql.DriverManager;

    public class Connect {

    public static void main(String args[]) {
    Connection con = null;

    try {
    String username = "root";
    String password = "pwd123";
    String url = "jdbc:mysql://localhost:3306/mysql";
    Class.forName("com.mysql.jdbc.Driver").newInstance ();
    con = DriverManager.getConnection(url, username, password);
    System.out.println("Connection Established.");
    }
    catch(Exception e) {
    System.err.println("Cannot Connect to DB. Exception: " + e.getMessage());
    }

    finally
    {
    if(con != null)
    {
    try
    {
    con.close();
    }

    catch(Exception e) {}
    }
    }
    }
    }

    Thanks

  2. #2
    habibiwalla is offline Member
    Join Date
    Aug 2009
    Posts
    2
    Rep Power
    0

    Default

    com.mysql.jdbc.exceptions.MySQLSyntaxErrorExceptio n: 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(SQLErro r.java:1026)
    at com.mysql.jdbc.SQLError.createSQLException(SQLErro r.java:956)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3491)
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.ja va:3423)
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:19 36)
    at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java :2060)
    at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionIm pl.java:2536)
    at com.mysql.jdbc.ConnectionImpl.configureClientChara cterSet(ConnectionImpl.java:1751)
    at com.mysql.jdbc.ConnectionImpl.initializePropsFromS erver(ConnectionImpl.java:3425)
    at com.mysql.jdbc.ConnectionImpl.createNewIO(Connecti onImpl.java:2045)
    at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImp l.java:718)
    at com.mysql.jdbc.ConnectionImpl.getInstance(Connecti onImpl.java:298)
    at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:282)
    at java.sql.DriverManager.getConnection(libgcj.so.90)
    at java.sql.DriverManager.getConnection(libgcj.so.90)
    at Connect.main(Connect.java:14)

  3. #3
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    836
    Rep Power
    6

    Default

    Hi,
    If the connection is having problem ,It will tell "Access denied" error.It will not give the above mentioned error.Please delete the class file and recompile the above file and check it once.Let us see,where we are going wrong.The above error will not come for the code u have posted.
    -Regards
    Ramya
    Ramya:cool:

Similar Threads

  1. Syntax-Check Your XML
    By gilbertsavier in forum XML
    Replies: 0
    Last Post: 07-17-2009, 07:37 AM
  2. how to solve syntax error
    By pro85 in forum Java Applets
    Replies: 5
    Last Post: 04-06-2009, 11:20 AM
  3. Java JDBC/MySQL appropriate Syntax
    By thelinuxguy in forum Advanced Java
    Replies: 7
    Last Post: 02-10-2009, 07:57 PM
  4. Replies: 2
    Last Post: 08-08-2007, 10:52 AM
  5. syntax error
    By gabriel in forum New To Java
    Replies: 3
    Last Post: 08-03-2007, 03:26 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •