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
Posted by: Alin Haid
Date: August 30, 2009 08:36AM

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) {}
}
}
}
}

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.