Hello!
Im doing a jsp-solution with mysql.
I'm using a "Bean" that do all "SELECT" "INSERT" etc.
My problem is:
if I want to update a row a call on the method "setUpdate()"which looks like:
("key" is my primarykey and it's a "varchar" )
--------------------------- Method -------------------------------------------
public void setUpdate(String i) throws IOException{
String nr=i;
String update="UPDATE tider SET fut1='"+getNamntag()+"', eut1='"+getNamntag2()+"', fut2='"+getMednamntag()+"', eut2='"+getMednamntag2()+"',grupput='"+getGrupput( )+"', ledig="+0+" WHERE key = '"+nr+"'";
try{
Class.forName(driverName);
}
catch(ClassNotFoundException cfn){
System.out.println(cfn);
}
try{
Connection con = DriverManager.getConnection(fileURL,"", "");
Statement updateStatement=con.createStatement();
System.out.println(update);
int noOfRows=updateStatement.executeUpdate(update);
}
catch(SQLException sqe){
System.out.println(sqe);
}
}
-----------------------------------------------------------------------------
The problem is that I get this SQLException:
--------------------------SQLException----------------------------------
java.sql.SQLException: Syntax error or access violation, message from server: "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 'key = '3'' at line 1"
-----------------------------------------------------------------------------
If I print my Query it looks like:
UPDATE tider SET fut1='test', eut1='test', fut2='test', eut2='tws',grupput='1', ledig=0 WHERE key = '3'
Isn't that correct?
I really can't figure it out why I get this Exception.
Thanks for helping me!
// Digital_storm