[pgsql-jp: 26364] Re: executeUpdate()から戻ってこない

Kishimoto Yu kishimoto @ bisonsoft.co.jp
2002年 6月 13日 (木) 15:57:13 JST


森岡さんこんにちは、Kishimoto と申します、
お世話になります。

On Thu, 13 Jun 2002 13:25:09 +0900
nokihara @ fecdev.furuno.co.jp (森岡郁子) 様 wrote:

> サンプルプログラムを作成したのですが、executeUpdate()を実行するとこのメソッドから
> ぬけてきていないような現象になっているような感じです。

当方の環境では、以下のコードで正常に実行できています。
(アプレットがよくわからないので、コンソールアプリに
変更してあります)

RedHatLinux
PostgreSQL 7.1.3
JDK 1.3.1

---[sample.java]---
import java.sql.*;
import java.awt.*;

public class sample {
        public  static void main(String args[]) {
                String url="jdbc:postgresql:testdb";
                String user="postgres";
                String passwd="";


                try{
                        Class.forName("org.postgresql.Driver");
                        Connection con = DriverManager.getConnection(url,user, passwd);
                        Statement st = con.createStatement();
                        System.out.println("clear createStatement()");

                        st.executeUpdate( "CREATE TABLE employee( EMPNO CHAR(6), FIRSTNAME VARCHAR(12) )" );
                        System.out.println("clear executeUpdate()\n");
                        System.out.println("***Table: employee created");

                        st.executeUpdate("INSERT INTO employee VALUES ('000000','morioka')");
                        st.executeUpdate("INSERT INTO employee VALUES ('000001','kitajima')");
                        System.out.println("***Two records added");

                        //Query and display results
                        ResultSet rs = st.executeQuery("SELECT * FROM employee");
                        System.out.println("***Results from table employee");

                        while(rs.next()){
                                System.out.print("EMPNO=" + rs.getString(1) + ",");
                                System.out.print(" FIRSTNAME=" + rs.getString(2) + "\n");
                        }

                        //Remvove table: employee  //Step 7
                        st.executeUpdate("Drop table employee");
                        System.out.println("***Table: employee deleted");

                        rs.close();
                        st.close();
                        con.close();

                }catch(SQLException e){
                        e.printStackTrace();
                }catch(Exception e){
                        e.printStackTrace();
                }
        }
}

---[実行結果]---
$ java sample
clear createStatement()
clear executeUpdate()

***Table: employee created
***Two records added
***Results from table employee
EMPNO=000000, FIRSTNAME=morioka
EMPNO=000001, FIRSTNAME=kitajima
***Table: employee deleted

--

原因は想像できないのですが、PostgreSQLの
問題ではないのではないでしょうか?

それでは、失礼いたします。

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 Kishimoto Yu <kishimoto @ bisonsoft.co.jp>




pgsql-jp メーリングリストの案内