1 //Set Null insert statement without parameterise on cache tables T1 test it by wasNull()
9 public static void main(String
[] arg
)
13 Class
.forName("csql.jdbc.JdbcSqlDriver");
14 Connection con
=DriverManager
.getConnection("jdbc:gateway","root","manager");
15 Statement cStmt
=con
.createStatement();
16 PreparedStatement stmt
=null,selStmt
=null;
17 stmt
=con
.prepareStatement("INSERT INTO T1(f1,f3,f5,f6,f7,f8,f9) VALUES(?,?,?,?,?,?,?);");
22 stmt
.setByte(2,(byte)(i
+2));
23 stmt
.setFloat(3,(float)1000+i
);
24 stmt
.setString(4, String
.valueOf("CSQL"+i
));
25 stmt
.setDate(5,Date
.valueOf("2008-03-21"));
26 stmt
.setTime(6,Time
.valueOf("18:00:00"));
27 stmt
.setTimestamp(7,Timestamp
.valueOf("2008-03-21 18:00:00"));
28 ret
=stmt
.executeUpdate();
32 stmt
=con
.prepareStatement("INSERT INTO T1(f1,f2,f4,f6,f7,f8,f9) values(10,11,101,'CSQL10','2008-03-21','18:00:00','2008-03-21 18:00:00');");
38 selStmt
=con
.prepareStatement("Select * from T1");
40 rs
=selStmt
.executeQuery();
44 System
.out
.print("Tuple value is " + rs
.getInt(1)+ " ");
45 if(rs
.wasNull()) System
.out
.print(" NULL");
46 System
.out
.print(rs
.getShort(2) + " ");
47 if(rs
.wasNull()) System
.out
.print(" NULL");
48 System
.out
.print(rs
.getByte(3) + " ");
49 if(rs
.wasNull()) System
.out
.print(" NULL");
50 System
.out
.print(rs
.getLong(4) + " ");
51 if(rs
.wasNull()) System
.out
.print(" NULL");
52 System
.out
.print(rs
.getFloat(5) + " ");
53 if(rs
.wasNull()) System
.out
.print(" NULL");
54 System
.out
.print(rs
.getString(6) + " ");
55 if(rs
.wasNull()) System
.out
.print(" NULL");
56 System
.out
.print(rs
.getDate(7) + " ");
57 if(rs
.wasNull()) System
.out
.print(" NULL");
58 System
.out
.print(rs
.getTime(8) + " ");
59 if(rs
.wasNull()) System
.out
.print(" NULL");
60 System
.out
.println(rs
.getTimestamp(9) + " ");
61 if(rs
.wasNull()) System
.out
.println(" NULL");
68 System
.out
.println("Exception in Test: "+e
);