File Removed
[csql.git] / test / jdbc / Gateway / GwStmt7.java
blob1f23321c17c737a223eea48d5390a31af781214a
1 //delete tuple with WHERE clause having params (DELETE FROM T1 WHERE f1=?AND f9=?) using gateway
2 import java.sql.*;
3 /**
5 * @author bijaya
6 */
7 public class GwStmt7 {
8 public static void main(String[] arg)
10 try
12 Class.forName("csql.jdbc.JdbcSqlDriver");
13 Connection con=DriverManager.getConnection("jdbc:gateway","root","manager");
14 Statement cStmt=con.createStatement();
15 PreparedStatement stmt=null,selStmt=null;
16 stmt=con.prepareStatement("INSERT INTO T1 VALUES(?,?,?,?,?,?,?,?,?);");
17 int ret=0;
18 for(int i=0;i<10;i++)
20 stmt.setInt(1,i);
21 stmt.setShort(2,(short)(i+1));
22 stmt.setByte(3,(byte)(i+2));
23 stmt.setLong(4,(long)i);
24 stmt.setFloat(5,(float)1000+i);
25 stmt.setString(6, String.valueOf("Cache"+i));
26 stmt.setDate(7,Date.valueOf("2008-03-21"));
27 stmt.setTime(8,Time.valueOf("18:00:00"));
28 stmt.setTimestamp(9,Timestamp.valueOf("2008-03-21 18:00:00"));
29 ret=stmt.executeUpdate();
30 if(ret!=1) break;
32 stmt.close();
33 con.commit();
34 selStmt=con.prepareStatement("Select * from T1");
35 ResultSet rs=null;
36 rs=selStmt.executeQuery();
37 while(rs.next())
39 System.out.println("Tuple value is " + rs.getInt(1) + " "+
40 rs.getShort(2) + " "+
41 rs.getByte(3) + " "+
42 rs.getLong(4) + " "+
43 rs.getFloat(5) + " "+
44 rs.getString(6) + " "+
45 rs.getDate(7) + " "+
46 rs.getTime(8) + " "+
47 rs.getTimestamp(9) + " "
51 rs.close();
52 con.commit();
53 ret=0;
54 stmt=con.prepareStatement("DELETE FROM T1 WHERE f1=? AND f9=?;");
55 for(int i=0;i<10;i++)
57 stmt.setInt(1,3);
58 stmt.setTimestamp(2,Timestamp.valueOf("2008-03-21 18:00:00"));
59 ret=stmt.executeUpdate();
60 if(ret!=1) break;
62 stmt.close();
63 con.commit();
64 selStmt=con.prepareStatement("Select * from T1");
65 rs=null;
66 rs=selStmt.executeQuery();
67 System.out.println();
68 while(rs.next())
70 System.out.println("Tuple value is " + rs.getInt(1) + " "+
71 rs.getShort(2) + " "+
72 rs.getByte(3) + " "+
73 rs.getLong(4) + " "+
74 rs.getFloat(5) + " "+
75 rs.getString(6) + " "+
76 rs.getDate(7) + " "+
77 rs.getTime(8) + " "+
78 rs.getTimestamp(9) + " "
82 rs.close();
83 con.commit();
84 con.close();
85 }catch(Exception e) {
86 System.out.println("Exception in Test: "+e);
87 e.printStackTrace();