adding test scripts
[csql.git] / test / sqlnetwork / Jdbcnetwork / StmtTest5.java
blob88e67a09c09c31dc199e7ae109b9106089f8f214
1 //CREATE TABLE T1 (f1 integer, f2 smallint, f3 tinyint,f4 bigint, f5 float, f6 char(10), f7 date, f8 time, f9 timestamp);
2 import java.sql.*;
3 public class StmtTest5
5 public static void main(String[] args)
7 try
9 Class.forName("csql.jdbc.JdbcSqlDriver");
10 Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/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 VALUES (?,?,?,?,?,?,?,?,?);");
16 stmt.setInt(1, 1);
17 stmt.setShort(2,(short)2);
18 stmt.setByte(3,(byte)3);
19 stmt.setLong(4,(long)4);
20 stmt.setFloat(5,(float)5);
21 stmt.setString(6, String.valueOf(5));
22 stmt.setDate(7,Date.valueOf("2008-03-21"));
23 stmt.setTime(8,Time.valueOf("18:00:00"));
24 stmt.setTimestamp(9,Timestamp.valueOf("2008-03-21 18:00:00"));
25 stmt.executeUpdate();
26 stmt.close();
27 con.commit();
29 selStmt = con.prepareStatement("SELECT * from T1 where f1 = ?;");
30 ResultSet rs = null;
32 selStmt.setInt(1, 1);
33 rs = selStmt.executeQuery();
34 while (rs.next())
36 System.out.println("Tuple value is " + rs.getInt(1) + " "+
37 rs.getShort(2) + " "+
38 rs.getByte(3) + " "+
39 rs.getLong(4) + " "+
40 rs.getFloat(5) + " "+
41 rs.getString(6) + " "+
42 rs.getDate(7) + " "+
43 rs.getTime(8) + " "+
44 rs.getTimestamp(9) + " "
47 rs.close();
48 selStmt.close();
50 cStmt.execute("DROP TABLE T1 ;");
51 con.close();
52 }catch(Exception e) {
53 System.out.println("Exception in Test: "+e);
54 e.printStackTrace();