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(3,(long)i
);
25 stmt
.setFloat(4,(float)1000+i
);
26 stmt
.setString(5, String
.valueOf("Nihar"+i
));
27 stmt
.setDate(6,Date
.valueOf("2008-03-21"));
28 if(System
.getenv("DSN").equals("oracle"))
29 stmt
.setDate(7,Date
.valueOf("2009-04-22"));
31 stmt
.setTime(7,Time
.valueOf("18:00:00"));
32 stmt
.setTimestamp(8,Timestamp
.valueOf("2008-03-21 18:00:00"));
33 ret
=stmt
.executeUpdate();
38 selStmt
=con
.prepareStatement("SELECT * FROM t1 where f1 = ? ");
41 //selStmt.setShort(2,(short)3);
42 //selStmt.setByte(1,(byte)4);
43 rs
=selStmt
.executeQuery();
46 if(System
.getenv("DSN").equals("oracle")){
47 System
.out
.println("Tuple value is " + rs
.getInt(1) + " "+
51 rs
.getString(5) + " "+
54 rs
.getTimestamp(8) + " "
58 System
.out
.println("Tuple value is " + rs
.getInt(1) + " "+
62 rs
.getString(5) + " "+
65 rs
.getTimestamp(8) + " "
68 System
.out
.println("Yes");
74 System
.out
.println("Exception in Test: "+e
);