1 //NULL Tset "INSERT null values to some fields with and without parameters"
5 public static void main(String
[] arg
)
9 Class
.forName("csql.jdbc.JdbcSqlDriver");
10 Connection con
=DriverManager
.getConnection("jdbc:csql","root","manager");
11 Statement cStmt
=con
.createStatement();
12 cStmt
.execute("CREATE TABLE T1 (f1 integer, f2 smallint, f3 tinyint, f4 bigint, f5 float, f6 char(10), f7 date, f8 time, f9 timestamp);");
14 PreparedStatement stmt
=null,selStmt
=null;
15 stmt
=con
.prepareStatement("INSERT INTO T1(f1,f3,f5,f6,f7,f8,f9) VALUES(?,?,?,?,?,?,?);");
20 stmt
.setByte(2,(byte)(i
+2));
21 stmt
.setFloat(3,(float)1000+i
);
22 stmt
.setString(4, String
.valueOf("Nihar"+i
));
23 stmt
.setDate(5,Date
.valueOf("2008-03-21"));
24 stmt
.setTime(6,Time
.valueOf("18:00:00"));
25 stmt
.setTimestamp(7,Timestamp
.valueOf("2008-03-21 18:00:00"));
26 ret
=stmt
.executeUpdate();
30 stmt
=con
.prepareStatement("INSERT INTO T1(f1,f2,f4,f6,f7,f8,f9) values(10,11,101,'Nihar10','2008-03-21','18:00:00','2008-03-21 18:00:00');");
36 selStmt
=con
.prepareStatement("Select * from T1");
38 rs
=selStmt
.executeQuery();
41 System
.out
.println("Tuple value is " + rs
.getInt(1) + " "+
46 rs
.getString(6) + " "+
49 rs
.getTimestamp(9) + " "
56 cStmt
.executeUpdate("Drop table T1;");
59 System
.out
.println("Exception in Test: "+e
);