File Removed
[csql.git] / test / jdbc / Statement / StmtTest8.java
blob28a638a528b1c15834892eb64bf99f2263ad28c9
1 //NULL Tset "INSERT null values to some fields with and without parameters"
2 import java.sql.*;
3 public class StmtTest8
5 public static void main(String[] arg)
7 try
9 Class.forName("csql.jdbc.JdbcSqlDriver");
10 Connection con=DriverManager.getConnection("jdbc: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);");
13 con.commit();
14 PreparedStatement stmt=null,selStmt=null;
15 stmt=con.prepareStatement("INSERT INTO T1(f1,f3,f5,f6,f7,f8,f9) VALUES(?,?,?,?,?,?,?);");
16 int ret=0;
17 for(int i=0;i<10;i++)
19 stmt.setInt(1,i);
20 stmt.setByte(2,(byte)(i+2));
21 stmt.setFloat(3,(float)1000+i);
22 stmt.setString(4, String.valueOf("Nihar"+i));
23 stmt.setDate(5,Date.valueOf("2008-03-21"));
24 stmt.setTime(6,Time.valueOf("18:00:00"));
25 stmt.setTimestamp(7,Timestamp.valueOf("2008-03-21 18:00:00"));
26 ret=stmt.executeUpdate();
27 if(ret!=1) break;
29 con.commit();
30 stmt=con.prepareStatement("INSERT INTO T1(f1,f2,f4,f6,f7,f8,f9) values(10,11,101,'Nihar10','2008-03-21','18:00:00','2008-03-21 18:00:00');");
31 stmt.executeUpdate();
33 stmt.close();
34 con.commit();
36 selStmt=con.prepareStatement("Select * from T1");
37 ResultSet rs=null;
38 rs=selStmt.executeQuery();
39 while(rs.next())
41 System.out.println("Tuple value is " + rs.getInt(1) + " "+
42 rs.getShort(2) + " "+
43 rs.getByte(3) + " "+
44 rs.getLong(4) + " "+
45 rs.getFloat(5) + " "+
46 rs.getString(6) + " "+
47 rs.getDate(7) + " "+
48 rs.getTime(8) + " "+
49 rs.getTimestamp(9) + " "
53 rs.close();
54 con.commit();
56 cStmt.executeUpdate("Drop table T1;");
57 con.close();
58 }catch(Exception e) {
59 System.out.println("Exception in Test: "+e);
60 e.printStackTrace();