Problem with connecting to MySQL server
Posted by: fingolion fingu
Date: April 26, 2009 12:11PM

Hi there!

I'm kinda newbie with both Java and MySQL and, at the moment, I'm kinda lost :P I'm trying to connect to a MySQL database, through a Java program. I'm working with Eclipse, already downloaded the Connector/J and put it in the classpath. By the way, I'm using ubuntu 9.04 if that makes any difference at all. I hope you can help me! :> Here's the code:

public EskaeraDB(){
try{

url = "jdbc:mysql://localhost/mydb";
System.out.println("kaixo");
Class.forName ("com.mysql.jdbc.Driver");
System.out.println("hemen nago");
konexio = DriverManager.getConnection(url,erabDB,pasDB);
System.out.println("hemen nago2");
statement = konexio.createStatement();
System.out.println ("Database connection established");
}
catch(SQLException sqlExc){
System.out.println("SQL Exception: "+sqlExc.getMessage());
sqlExc.printStackTrace();
}
catch(ClassNotFoundException classExc){
System.out.println("Ez da JDBC aurkitu");
}

}

And here, the error log I get when running:

kaixo
hemen nago
SQL Exception: 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
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:3515)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3447)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1951)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2101)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2548)
at com.mysql.jdbc.ConnectionImpl.configureClientCharacterSet(ConnectionImpl.java:1768)
at com.mysql.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:3444)
at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2062)
at com.mysql.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:723)
at com.mysql.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:298)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:282)
at java.sql.DriverManager.getConnection(libgcj.so.90)
at java.sql.DriverManager.getConnection(libgcj.so.90)
at pak.EskaeraDB.<init>(EskaeraDB.java:26)
at pak.Nagusia.main(Nagusia.java:5)


Due to the "println"'s it's kinda obvious that it stops in the "getConnection" part, but I have no idea at all of what to do x_x Thank you for your help!

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.