CONEXION CON MYSQL
Publicado por ENARA (62 intervenciones) el 27/12/2006 23:35:10
Buenas, creo que he conseguido conectarme con mysql pero tengo este error:
---------------------------------------------------------------------------------------------------------------------------
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 '[C@13f5d07' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3170)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3099)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1169)
...
---------------------------------------------------------------------------------------------------------------------------
con esto:
int nivelCargo=0;
String url=null;
Connection conn=null;
Statement stmt=null;
ResultSet rset=null;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String servidor="localhost";
String baseDatos="bd";
String user="usuario";
String passwd="pw";
conn = DriverManager.getConnection(
"jdbc:mysql://"+servidor+"/"+baseDatos+
"?user="+user+"&password="+passwd);
if (conn==null) System.out.println("CONEXION FALLIDA");
stmt=conn.createStatement();
rset=stmt.executeQuery("select p.ncargo from personal p where p.login="+login+" and p.password="+contraseña+"");
if(rset.next()==true){
nivelCargo=rset.getInt("nCargo");
}
}
catch (ClassNotFoundException ex1) {
ex1.printStackTrace();
}
catch (SQLException ex2) {
ex2.printStackTrace();
}
catch (IllegalAccessException ex) {
}
catch (InstantiationException ex) {
}
finally{
try{
rset.close();
stmt.close();
conn.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
ME PODRÍAS DECIR A QUE SE DEBE??
GRACIAS
FELIZ NAVIDAD
---------------------------------------------------------------------------------------------------------------------------
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 '[C@13f5d07' at line 1
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2870)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1573)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3170)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3099)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1169)
...
---------------------------------------------------------------------------------------------------------------------------
con esto:
int nivelCargo=0;
String url=null;
Connection conn=null;
Statement stmt=null;
ResultSet rset=null;
try {
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String servidor="localhost";
String baseDatos="bd";
String user="usuario";
String passwd="pw";
conn = DriverManager.getConnection(
"jdbc:mysql://"+servidor+"/"+baseDatos+
"?user="+user+"&password="+passwd);
if (conn==null) System.out.println("CONEXION FALLIDA");
stmt=conn.createStatement();
rset=stmt.executeQuery("select p.ncargo from personal p where p.login="+login+" and p.password="+contraseña+"");
if(rset.next()==true){
nivelCargo=rset.getInt("nCargo");
}
}
catch (ClassNotFoundException ex1) {
ex1.printStackTrace();
}
catch (SQLException ex2) {
ex2.printStackTrace();
}
catch (IllegalAccessException ex) {
}
catch (InstantiationException ex) {
}
finally{
try{
rset.close();
stmt.close();
conn.close();
}
catch(SQLException e){
e.printStackTrace();
}
}
ME PODRÍAS DECIR A QUE SE DEBE??
GRACIAS
FELIZ NAVIDAD
Valora esta pregunta


0