From 73bd36df4be91452e7f5689d13102cad1c6101b8 Mon Sep 17 00:00:00 2001 From: niharlcp1 Date: Wed, 29 Oct 2008 15:08:57 +0000 Subject: [PATCH] Test Script added for NULL test "INSERT null values to some fields with and without parameters" --- test/jdbc/Statement/Makefile | 2 +- test/jdbc/Statement/StmtTest8.java | 64 +++++++++++++++++++++++++++++++++++++ test/jdbc/Statement/exp.test008.ksh | 11 +++++++ test/jdbc/Statement/test008.ksh | 14 ++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 test/jdbc/Statement/StmtTest8.java create mode 100644 test/jdbc/Statement/exp.test008.ksh create mode 100755 test/jdbc/Statement/test008.ksh diff --git a/test/jdbc/Statement/Makefile b/test/jdbc/Statement/Makefile index 6da86a82..b77e8318 100644 --- a/test/jdbc/Statement/Makefile +++ b/test/jdbc/Statement/Makefile @@ -2,7 +2,7 @@ OSNAME = $(shell uname -s) JAVAC = javac TARGETS = StmtTests StmtTests: StmtTest1.java StmtTest2.java StmtTest3.java StmtTest4.java \ - StmtTest5.java StmtTest6.java StmtTest7.java + StmtTest5.java StmtTest6.java StmtTest7.java StmtTest8.java javac Stmt*.java chmod +x *.ksh clean: diff --git a/test/jdbc/Statement/StmtTest8.java b/test/jdbc/Statement/StmtTest8.java new file mode 100644 index 00000000..28a638a5 --- /dev/null +++ b/test/jdbc/Statement/StmtTest8.java @@ -0,0 +1,64 @@ +//NULL Tset "INSERT null values to some fields with and without parameters" +import java.sql.*; +public class StmtTest8 +{ + public static void main(String[] arg) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con=DriverManager.getConnection("jdbc:csql","root","manager"); + Statement cStmt=con.createStatement(); + cStmt.execute("CREATE TABLE T1 (f1 integer, f2 smallint, f3 tinyint, f4 bigint, f5 float, f6 char(10), f7 date, f8 time, f9 timestamp);"); + con.commit(); + PreparedStatement stmt=null,selStmt=null; + stmt=con.prepareStatement("INSERT INTO T1(f1,f3,f5,f6,f7,f8,f9) VALUES(?,?,?,?,?,?,?);"); + int ret=0; + for(int i=0;i<10;i++) + { + stmt.setInt(1,i); + stmt.setByte(2,(byte)(i+2)); + stmt.setFloat(3,(float)1000+i); + stmt.setString(4, String.valueOf("Nihar"+i)); + stmt.setDate(5,Date.valueOf("2008-03-21")); + stmt.setTime(6,Time.valueOf("18:00:00")); + stmt.setTimestamp(7,Timestamp.valueOf("2008-03-21 18:00:00")); + ret=stmt.executeUpdate(); + if(ret!=1) break; + } + con.commit(); + 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');"); + stmt.executeUpdate(); + + stmt.close(); + con.commit(); + + selStmt=con.prepareStatement("Select * from T1"); + ResultSet rs=null; + rs=selStmt.executeQuery(); + while(rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1) + " "+ + rs.getShort(2) + " "+ + rs.getByte(3) + " "+ + rs.getLong(4) + " "+ + rs.getFloat(5) + " "+ + rs.getString(6) + " "+ + rs.getDate(7) + " "+ + rs.getTime(8) + " "+ + rs.getTimestamp(9) + " " + ); + + } + rs.close(); + con.commit(); + + cStmt.executeUpdate("Drop table T1;"); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + } + } +} + diff --git a/test/jdbc/Statement/exp.test008.ksh b/test/jdbc/Statement/exp.test008.ksh new file mode 100644 index 00000000..68e51a28 --- /dev/null +++ b/test/jdbc/Statement/exp.test008.ksh @@ -0,0 +1,11 @@ +Tuple value is 0 0 2 0 1000.0 Nihar0 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 1 0 3 0 1001.0 Nihar1 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 2 0 4 0 1002.0 Nihar2 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 3 0 5 0 1003.0 Nihar3 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 4 0 6 0 1004.0 Nihar4 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 5 0 7 0 1005.0 Nihar5 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 6 0 8 0 1006.0 Nihar6 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 7 0 9 0 1007.0 Nihar7 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 8 0 10 0 1008.0 Nihar8 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 9 0 11 0 1009.0 Nihar9 2008-03-21 18:00:00 2008-03-21 18:00:00.0 +Tuple value is 10 11 0 101 0.0 Nihar10 2008-03-21 18:00:00 2008-03-21 18:00:00.0 diff --git a/test/jdbc/Statement/test008.ksh b/test/jdbc/Statement/test008.ksh new file mode 100755 index 00000000..5d2f74c8 --- /dev/null +++ b/test/jdbc/Statement/test008.ksh @@ -0,0 +1,14 @@ +#!/bin/sh +TESTFILE=${PWD}/jdbc/Statement/StmtTest8.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Statement +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest8 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; -- 2.11.4.GIT