1
J'ai essayé d'exécuter le code suivant dans un programme Java pendant un certain temps à partir d'un bouton. J'ai tout essayé mais il y a toujours une exception. J'ai déjà fait la table et y ai mis un seul disque.MySql Java Connectivity throws exception. (UPDATE)
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try{
Class.forName("java.sql.Driver");
String UID="root";
String PWD="123";
String DB_URL="jdbc:mysql://localhost:3306/project";
Connection conn=DriverManager.getConnection(DB_URL,UID,PWD);
String CatalogID=jTextField3.getText();
String Title=jTextField4.getText();
String Author=jTextField5.getText();
String Price=jTextField6.getText();
String Category=jTextField7.getText();
Statement stmt=conn.createStatement();
String q="UPDATE table1 SET title='"+Title+"' author='"+Author+"' category='"+Category+"' price="+Price+" WHERE id="+CatalogID+";";
stmt.executeUpdate(q);
}
catch(Exception e){
JOptionPane.showMessageDialog(null,"Error");
}
}
Essayé, le problème persiste ' –
Juste un projet d'école. Nous venons de commencer à apprendre sql. –
quelle exception obtenez-vous exactement? –