If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > You have an error in your SQL syntax; check the manual that corresponds to your MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-30-09, 10:44
habibiwalla habibiwalla is offline
Registered User
 
Join Date: Aug 2009
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 08-31-09, 05:55
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
what is the exact trace of the exception ?
use e.printStackTrace();

when you get the linenumber where the error occurs that will tell you where to look further.
Reply With Quote
  #3 (permalink)  
Old 08-31-09, 06:33
habibiwalla habibiwalla is offline
Registered User
 
Join Date: Aug 2009
Posts: 2
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)
Reply With Quote
  #4 (permalink)  
Old 08-31-09, 14:04
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
The error occurs at the moment of establishing a connection, which is refused.

Some possibilities:

a) UNIX environments are case sensitive, Windows isn't, make sure you consistently use the same case.
b) you are not allowed to access the port because of some firewalll setting
c) mysql refuses a connection because for some reason the username is not allowed access, which would be strange for "root" but there you go.

Don't think it's actual SQL syntax, more a case of not getting through.
Reply With Quote
  #5 (permalink)  
Old 08-31-09, 14:08
BettingSherlock BettingSherlock is offline
Registered User
 
Join Date: May 2007
Posts: 78
Have a read through this:
MySQL :: Problem with connecting to MySQL server

seems to have done the trick.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On