Results 1 to 3 of 3
- 08-30-2009, 04:39 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 2
- Rep Power
- 0
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
- 08-31-2009, 12:50 PM #2
Member
- Join Date
- Aug 2009
- Posts
- 2
- Rep Power
- 0
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)
- 08-31-2009, 02:50 PM #3
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
RamyaRamya:cool:
Similar Threads
-
Syntax-Check Your XML
By gilbertsavier in forum XMLReplies: 0Last Post: 07-17-2009, 07:37 AM -
how to solve syntax error
By pro85 in forum Java AppletsReplies: 5Last Post: 04-06-2009, 11:20 AM -
Java JDBC/MySQL appropriate Syntax
By thelinuxguy in forum Advanced JavaReplies: 7Last Post: 02-10-2009, 07:57 PM -
How to check the number of applications connected to MySQL DB
By sandeepspatil in forum JDBCReplies: 2Last Post: 08-08-2007, 10:52 AM -
syntax error
By gabriel in forum New To JavaReplies: 3Last Post: 08-03-2007, 03:26 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks