*** empty log message ***
[csql.git] / test / jdbc / Statement / TestScript2.java
blob8c70b7d0b6252c3435077ada5f50193aa85aa4c1
1 //select Null test
2 import java.sql.*;
4 /**
6 * @author bijaya
7 */
8 public class TestScript2 {
10 public static void main(String[] args)
12 try
14 Class.forName("csql.jdbc.JdbcSqlDriver");
15 Connection con = DriverManager.getConnection("jdbc:csql", "root", "manager");
16 Statement cStmt = con.createStatement();
17 cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));");
18 PreparedStatement stmt = null, selStmt= null;
19 stmt = con.prepareStatement("INSERT INTO T1 VALUES (?, NULL);");
20 for (int i =0 ; i< 10 ; i++) {
21 stmt.setInt(1, i);
22 stmt.executeUpdate();
24 stmt.close();
25 con.commit();
26 selStmt = con.prepareStatement("SELECT * from T1 ;");
27 ResultSet rs = null;
28 //selStmt.setInt(1, i);
29 rs = selStmt.executeQuery();
30 while (rs.next())
32 int f1=rs.getInt(1);
33 if(rs.wasNull())
34 System.out.print(" NULL");
35 else
36 System.out.print(" "+ f1);
37 String f2=rs.getString(2);
38 if(rs.wasNull())
39 System.out.println(" NULL");
40 else
41 System.out.println(" "+ f2);
43 rs.close();
45 cStmt.executeUpdate("Drop table T1;");
46 con.close();
47 }catch(Exception e) {
48 System.out.println("Exception in Test: "+e);
49 e.printStackTrace();