File Removed
[csql.git] / test / jdbc / Gateway / GwStmt8.java
blob3c9888e2a85247ac5e2007e5befbdb6f58d20f3a
1 //Set Null insert statement without parameterise on cache tables T1 test it by wasNull()
2 import java.sql.*;
3 /**
5 * @author bijaya
6 */
7 public class GwStmt8
9 public static void main(String[] arg)
11 try
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(f1,f3,f5,f6,f7,f8,f9) VALUES(?,?,?,?,?,?,?);");
18 int ret=0;
19 for(int i=0;i<10;i++)
21 stmt.setInt(1,i);
22 stmt.setByte(2,(byte)(i+2));
23 stmt.setFloat(3,(float)1000+i);
24 stmt.setString(4, String.valueOf("CSQL"+i));
25 stmt.setDate(5,Date.valueOf("2008-03-21"));
26 stmt.setTime(6,Time.valueOf("18:00:00"));
27 stmt.setTimestamp(7,Timestamp.valueOf("2008-03-21 18:00:00"));
28 ret=stmt.executeUpdate();
29 if(ret!=1) break;
31 con.commit();
32 stmt=con.prepareStatement("INSERT INTO T1(f1,f2,f4,f6,f7,f8,f9) values(10,11,101,'CSQL10','2008-03-21','18:00:00','2008-03-21 18:00:00');");
33 stmt.executeUpdate();
35 stmt.close();
36 con.commit();
38 selStmt=con.prepareStatement("Select * from T1");
39 ResultSet rs=null;
40 rs=selStmt.executeQuery();
41 while(rs.next())
44 System.out.print("Tuple value is " + rs.getInt(1)+ " ");
45 if(rs.wasNull()) System.out.print(" NULL");
46 System.out.print(rs.getShort(2) + " ");
47 if(rs.wasNull()) System.out.print(" NULL");
48 System.out.print(rs.getByte(3) + " ");
49 if(rs.wasNull()) System.out.print(" NULL");
50 System.out.print(rs.getLong(4) + " ");
51 if(rs.wasNull()) System.out.print(" NULL");
52 System.out.print(rs.getFloat(5) + " ");
53 if(rs.wasNull()) System.out.print(" NULL");
54 System.out.print(rs.getString(6) + " ");
55 if(rs.wasNull()) System.out.print(" NULL");
56 System.out.print(rs.getDate(7) + " ");
57 if(rs.wasNull()) System.out.print(" NULL");
58 System.out.print(rs.getTime(8) + " ");
59 if(rs.wasNull()) System.out.print(" NULL");
60 System.out.println(rs.getTimestamp(9) + " ");
61 if(rs.wasNull()) System.out.println(" NULL");
63 rs.close();
64 con.commit();
66 con.close();
67 }catch(Exception e) {
68 System.out.println("Exception in Test: "+e);
69 e.printStackTrace();