scusate ho un problema devo eseguire l'update di una tabella...
devo modificare un campo ed ho un problemino...
non so che dito di execute usare....
questo è il codice della classe che si occupa della connessione al db
questo public void riceve questa stringa statementcodice:public void modificaScript(String statement) throws ClassNotFoundException, SQLException { Connection conn = null; Class.forName("com.mysql.jdbc.Driver"); String connessione=doit(); conn = (Connection) DriverManager.getConnection(connessione); Statement stmt = conn.createStatement(); stmt.executeUpdate(statement); stmt.close(); }
il problema è che ho provato a modificare lo Statement con Prepared Statementcodice:String statement="UPDATE script SET nomeScript = '"+nome+"' WHERE Codice='"+codiceScript+"'";
ma ottengo sempre questi errori
potreste dirmi come aiutarmi?....codice:java.sql.SQLException: 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 ''+'IPT LANGUAGE="JavaScript" TYPE="text/javascript" SRC="http://adserver.libero.' at line 1 at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2851) at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1531) at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1622) at com.mysql.jdbc.Connection.execSQL(Connection.java:2379) at com.mysql.jdbc.Connection.execSQL(Connection.java:2306) at com.mysql.jdbc.Statement.executeUpdate(Statement.java:1298) at MetaDataMapping.modificaScript(MetaDataMapping.java:189) at dataMapper.modificaScript(dataMapper.java:164) at BusinessDelegate.modificaScript(BusinessDelegate.java:152) at FontController.modificaScript(FontController.java:189) at B_visualizza$21.actionPerformed(B_visualizza.java:1216) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)

Rispondi quotando