[prev in list] [next in list] [prev in thread] [next in thread] 

List:       suse-programming-e
Subject:    Re: [suse-programming-e] Can not issue data manipulation
From:       Patrix Linux <patrixlinux () arcor ! de>
Date:       2006-01-16 17:18:02
Message-ID: 1137431883.6874.15.camel () acer-suse ! telkom ! net
[Download RAW message or body]

Hi Steve. I wish all luck for you.

Thank you very much for the solution. My problem has been solved.

Thank you very much.

On Mon, 2006-01-16 at 09:42 +0100, Steve Graegert wrote:
> On 1/16/06, Patrix Linux <patrixlinux@arcor.de> wrote:
> > 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);
> >                }
> >            }
> >
> >        }
> >
> 
> executeQuery() returns a result set, but an INSERT statement does not
> return a result.  Try execute(string sql) instead.
> 
> 	\Steve
> 
> --
> 
> Steve Graegert <graegerts@gmail.com>
> Software Consultant {C/C++ && Java && .NET}
> Office: +49 9131 7123988
> Mobile: +49 1520 9289212


-- 
To unsubscribe, email: suse-programming-e-unsubscribe@suse.com
For additional commands, email: suse-programming-e-help@suse.com
Archives can be found at: http://lists.suse.com/archive/suse-programming-e

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic