
Dear my friends... I am confused why my program does not run properly.The error message is: " Errorjava.sql.SQLException: Can not issue data manipulation statements with executeQuery(). ". Please help me. Tell me where my mistake. Thank you very much in advance. ====== Here is my table: " mysql> describe karyawan; +-----------+---------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+---------+------+-----+---------+-------+ | id | int(11) | YES | | NULL | | | namadepan | text | YES | | NULL | | +-----------+---------+------+-----+---------+-------+ 2 rows in set (0.00 sec) mysql> ". -------------------------- And here is my code: //package basisdata; import java.sql.*; import java.io.*; public class login { public static void main(String args[]) throws IOException{ BufferedReader stdin = new BufferedReader(new InputStreamReader(System.in)); String username,koderahasia,basisdata, id,namadepan, buff; basisdata = "rumahsakit"; int pilih; System.out.println("Login : "); try{ System.out.println("Username : "); username = stdin.readLine(); System.out.println("Kode rahasia : "); koderahasia = stdin.readLine(); Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection("jdbc:mysql://localhost/"+ basisdata, username, koderahasia); System.out.println("Udah konek"); System.out.println("Menu : "); System.out.println("1. Simpan data."); System.out.println("2. Edit data."); System.out.println("3. Hapus data."); System.out.println("4. Lihat data."); System.out.println("5. Exit."); System.out.println("Pilih menu !"); buff = stdin.readLine(); pilih = Integer.parseInt(buff); switch(pilih){ case 1: System.out.println("Proses simpan."); System.out.println("ID karyawan : "); id = stdin.readLine(); System.out.println("Nama depan : "); namadepan = stdin.readLine(); Statement pernyataan = connection.createStatement(); String sql = "insert into karyawan values("+id+",'"+namadepan+"');"; System.out.println(sql); pernyataan.executeQuery(sql); pernyataan.close(); System.out.println("Data udah disimpan"); break; case 2: System.out.println("Proses edit data."); break; case 3: System.out.println("Proses hapus data."); break; case 4: System.out.println("Proses lihat data."); break; default: System.out.println("Bye."); break; } connection.close(); }catch(Exception e){ System.out.println("Error"+e); } } }