Win a copy of Getting started with Java programming language this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

error in your SQL syntax  RSS feed

 
Faustina Angelina
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
 
somashaker goud
Ranch Hand
Posts: 56
  • 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.
 
praveen kumaar
Ranch Hand
Posts: 450
22
Android Chrome Eclipse IDE Google App Engine Java Notepad Oracle Ubuntu Windows
  • 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?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!