2 //select tuple with WHERE clause having param for some fields(SELECT * FROM T1 WHERE f1=?AND f2=? AND f3=?)
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 VALUES(?,?,?,?,?,?,?,?,?);");
22 stmt
.setShort(2,(short)(i
+1));
23 stmt
.setByte(3,(byte)(i
+2));
24 stmt
.setLong(4,(long)i
);
25 stmt
.setFloat(5,(float)1000+i
);
26 stmt
.setString(6, String
.valueOf("Nihar"+i
));
27 stmt
.setDate(7,Date
.valueOf("2008-03-21"));
28 stmt
.setTime(8,Time
.valueOf("18:00:00"));
29 stmt
.setTimestamp(9,Timestamp
.valueOf("2008-03-21 18:00:00"));
30 ret
=stmt
.executeUpdate();
35 selStmt
=con
.prepareStatement("SELECT * FROM T1 where f1 = ? ");
38 //selStmt.setShort(2,(short)3);
39 //selStmt.setByte(1,(byte)4);
40 rs
=selStmt
.executeQuery();
43 System
.out
.println("Tuple value is " + rs
.getInt(1) + " "+
48 rs
.getString(6) + " "+
51 rs
.getTimestamp(9) + " "
53 System
.out
.println("Yes");
59 System
.out
.println("Exception in Test: "+e
);