DROP CLASS JM_USR;
CREATE CLASS JM_USR (
USR_ID CHAR VARYING(253) NOT NULL PRIMARY KEY,
USR_NCK CHAR VARYING(253) NOT NULL UNIQUE,
USR_PW CHAR(22) NOT NULL,
USR_ATH CHAR(22) ,
USR_PT NUMERIC(38, 8) DEFAULT 0
);
1 package jeemin;
2
3 import java.sql.*;
4
5 import cubrid.jdbc.driver.*;
6
7 public class Test1{
8 public static void main(String[] args){
9 try{
10 Class.forName("cubrid.jdbc.driver.CUBRIDDriver");
11 Connection conn = DriverManager.getConnection("jdbc:cubrid:localhost:33000:jeemin:::", "jeemin", "jeemin");
12 PreparedStatement ps = conn.prepareStatement("SELECT JM_USR, USR_NCK, USR_PT FROM JM_USR WHERE USR_ID=? AND USR_PW=?");
13 ps.setString(1, "test");
14 ps.setString(2, "KFq5RI0nUe5X7Of3YsOQlQ");
15
16 CUBRIDResultSet rs = (CUBRIDResultSet)ps.executeQuery();
17
18 if(rs.next()){
19 System.out.println(rs.getString("USR_NCK"));
20 }
21
22 CUBRIDPreparedStatement ps2 = (CUBRIDPreparedStatement)conn.prepareStatement("UPDATE JM_USR SET USR_ATH=? WHERE JM_USR=?");
23 ps2.setString(1, "ABCDEFG");
24 ps2.setOID(2, rs.getOID("JM_USR"));
25 ps2.execute();
26 ps2.close();
27
28 rs.getString("USR_NCK");
29
30 rs.close();
31 ps.close();
32 conn.close();
33 }catch(Exception e){
34 e.printStackTrace();
35 }
36
37 }
38 }
cubrid.jdbc.driver.CUBRIDException: Attempt to access a closed ResultSet.
at cubrid.jdbc.driver.CUBRIDResultSet.checkIsOpen(CUBRIDResultSet.java:1648)
at cubrid.jdbc.driver.CUBRIDResultSet.findColumn(CUBRIDResultSet.java:670)
at cubrid.jdbc.driver.CUBRIDResultSet.getString(CUBRIDResultSet.java:559)
at jeemin.Test1.main(Test1.java:28)
28번째 라인에서 rs가 이미 닫혔다고 나옵니다.
정확하게 닫히는 이유가 먼가요?
cubrid에서는 세그먼트를 2개 열면 첫번째 세그먼트가 자동으로 닫히나요?
정확하게 어떤 경우에 닫히는지를 정의해 주실수 있나요?