1 //CREATE TABLE T1 (f1 integer, f2 smallint, f3 tinyint,f4 bigint, f5 float, f6 char(10), f7 date, f8 time, f9 timestamp);
5 public static void main(String
[] args
)
9 Class
.forName("csql.jdbc.JdbcSqlDriver");
10 Connection con
= DriverManager
.getConnection("jdbc:csql://localhost:5678/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 VALUES (?,?,?,?,?,?,?,?,?);");
17 stmt
.setShort(2,(short)2);
18 stmt
.setByte(3,(byte)3);
19 stmt
.setLong(4,(long)4);
20 stmt
.setFloat(5,(float)5);
21 stmt
.setString(6, String
.valueOf(5));
22 stmt
.setDate(7,Date
.valueOf("2008-03-21"));
23 stmt
.setTime(8,Time
.valueOf("18:00:00"));
24 stmt
.setTimestamp(9,Timestamp
.valueOf("2008-03-21 18:00:00"));
29 selStmt
= con
.prepareStatement("SELECT * from T1 where f1 = ?;");
33 rs
= selStmt
.executeQuery();
36 System
.out
.println("Tuple value is " + rs
.getInt(1) + " "+
41 rs
.getString(6) + " "+
44 rs
.getTimestamp(9) + " "
50 cStmt
.execute("DROP TABLE T1 ;");
53 System
.out
.println("Exception in Test: "+e
);