Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

error in your SQL syntax

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
private void jButton_saveActionPerformed(java.awt.event.ActionEvent evt) {                                            
       // TODO add your handling code here:
       String nama =jTextField_nama.getText();
       String nik =jTextField_nik.getText();
       String ip =jTextField_ip.getText();
       String shift =jTextField_shift.getText();
       String div =jTextField_div.getText();
       String uk =jTextField_uk.getText();
       String pic =jTextField_pic.getText();
       Date tanggal =jDateChooser1.getDate();
       String jam =jTextField_jamrsk.getText();
       String mslh =jTextField_masalah.getText();
       String analisa =jTextField_analisa.getText();
       String tindakan =jTextField_tindakan.getText();
       String rekom =jTextField_rekomen.getText();
       String part =jTextField_part.getText();
       Date lapor =jDateChooser2.getDate();
       Date mulai =jDateChooser3.getDate();
       Date bar =jDateChooser4.getDate();
       String total =jTextField_total.getText();
       String laporkan =jTextField_laporkan.getText();
       String kerjakan =jTextField_perbaiki.getText();
       
       openDB();
       try {
          stm = con.createStatement();
          stm.executeUpdate("insert into kerusakan  set nama='"+nama+"'"
                   + ",nik='"+nik+"'"
                   + ",pic='"+pic+"'"
                   + ",ip='"+ip+"'"
                   + ",shift='"+shift+"'"        
                   + ",div='"+div+"'"
                   + ",unitkerja='"+uk+"'"
                   + ",masalah='"+mslh+"'"
                   + ",analisa='"+analisa+"'"
                   + ",tindakan='"+tindakan+"'"
                   + ",rekomen='"+rekom+"'"
                   + ",part='"+part+"'"
                   + ",lapor='"+lapor+"'"
                   + ",laporkan='"+laporkan+"'"
                   + ",mulai='"+mulai+"'"
                   + ",bar='"+bar+"'"
                   + ",kerjakan='"+kerjakan+"'"
                   + ",tanggal='"+tanggal+"'"
                   + ",jam='"+jam+"'"
                   + ",total='"+total+"'");
                   
          JOptionPane.showMessageDialog(this, "Berhasil", "Pesan",
                  JOptionPane.INFORMATION_MESSAGE);
          } catch (SQLException e) {
            System.out.println(""+e);
         JOptionPane.showMessageDialog(this,"Gagal Menyimpan Data\n"+e,
                    "Pesan Error", JOptionPane.ERROR_MESSAGE);
       jTabbedPane2.setSelectedIndex(2);
   }                                            
   }

ERROR :
com.mysql.jdbc.exceptions.jdbc4.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 'div='TCT',unitkerja='PRODUCTION',masalah='',analisa='',tindakan='',rekomen='',pa' at line 1
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check your insert query . Actually I worked in oracle, where we wont use SET in insert instead SET will be used in update query.
 
Ranch Hand
Posts: 491
23
Eclipse IDE Firefox Browser Spring VI Editor AngularJS Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Faustina,
welcome to CodeRanch!
I added your topic to the JDBC forum may be here you will get a quick response.please UseCodeTags(← Click here for the info).

Kind Regards,
Praveen.
 
Faustina Angelina
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

somashaker goud wrote:check your insert query . Actually I worked in oracle, where we wont use SET in insert instead SET will be used in update query.

you mean SET should be delete?
 
    Bookmark Topic Watch Topic
  • New Topic