mysql - SQL - Java/Eclipse - UPDATE statement query [Re-asked, to insert more code] -
so want "update 'usertype' column in 'user' table email(/user) value obtained textbox " below database connection code (which 100% works)
import java.sql.connection; import java.sql.drivermanager; import java.sql.statement; import javax.swing.joptionpane; public class database_link { connection connect = null; statement state = null; public static connection dbconnector() { try{ class.forname("org.hsqldb.jdbcdriver"); connection connect = drivermanager.getconnection("jdbc:hsqldb:file: // db path ) joptionpane.showmessagedialog(null, "connection successful"); return connect; } catch (exception e) { joptionpane.showmessagedialog(null, "failed connection"); return null; } } }
below sql statement code error "the operator & undefined argument type(s) java.lang.string, java.lang.string"
jbutton grantbutton = new jbutton("grant seller access"); grantbutton.addactionlistener(new actionlistener() { public void actionperformed(actionevent arg0) { try { string update_query = "update user set usertype = 'seller' email = " & grantfield.gettext()";" //here error stated on eclipse preparedstatement pst = connect.preparestatement(update_query); pst.setstring(1, grantfield.gettext()); pst.execute(); joptionpane.showmessagedialog(null, "the request has been approved"); } catch (exception e) { e.printstacktrace(); } } });
sorry have repeated question
string update_query = "update user set usertype = 'seller' email = " & grantfield.gettext()";"
should like
string update_query = "update user set usertype = 'seller' email = ?"
Comments
Post a Comment