From 08864df713a68cfab6802ce5995c8c3c69ddb766 Mon Sep 17 00:00:00 2001 From: prabatuty Date: Sat, 6 Nov 2010 05:32:12 +0000 Subject: [PATCH] adding test scripts --- test/sqlgw/Makefile | 18 +++ test/sqlgw/Parameter/Makefile | 50 ++++++ test/sqlgw/Parameter/README | 15 ++ test/sqlgw/Parameter/common.h | 43 +++++ test/sqlgw/Parameter/csql.conf | 110 +++++++++++++ test/sqlgw/Parameter/exp.test001.ksh | 123 ++++++++++++++ test/sqlgw/Parameter/exp.test002.ksh | 12 ++ test/sqlgw/Parameter/exp.test003.ksh | 8 + test/sqlgw/Parameter/exp.test004.ksh | 15 ++ test/sqlgw/Parameter/exp.test005.ksh | 22 +++ test/sqlgw/Parameter/exp.test006.ksh | 14 ++ test/sqlgw/Parameter/paratest1.c | 194 ++++++++++++++++++++++ test/sqlgw/Parameter/paratest2.c | 194 ++++++++++++++++++++++ test/sqlgw/Parameter/paratest3.c | 240 ++++++++++++++++++++++++++++ test/sqlgw/Parameter/paratest4.c | 219 +++++++++++++++++++++++++ test/sqlgw/Parameter/paratest5.c | 187 ++++++++++++++++++++++ test/sqlgw/Parameter/paratest6.c | 192 ++++++++++++++++++++++ test/sqlgw/Parameter/test001.ksh | 83 ++++++++++ test/sqlgw/Parameter/test002.ksh | 84 ++++++++++ test/sqlgw/Parameter/test003.ksh | 84 ++++++++++ test/sqlgw/Parameter/test004.ksh | 84 ++++++++++ test/sqlgw/Parameter/test005.ksh | 84 ++++++++++ test/sqlgw/Parameter/test006.ksh | 85 ++++++++++ test/sqlgw/Select/Makefile | 57 +++++++ test/sqlgw/Select/README | 15 ++ test/sqlgw/Select/common.h | 43 +++++ test/sqlgw/Select/csql.conf | 110 +++++++++++++ test/sqlgw/Select/exp.test009.ksh | 77 +++++++++ test/sqlgw/Select/exp.test009.ksh.psql | 80 ++++++++++ test/sqlgw/Select/selecttest1.c | 133 +++++++++++++++ test/sqlgw/Select/selecttest2.c | 143 +++++++++++++++++ test/sqlgw/Select/selecttest3.c | 89 +++++++++++ test/sqlgw/Select/selecttest4.c | 66 ++++++++ test/sqlgw/Select/selecttest5.c | 30 ++++ test/sqlgw/Select/selecttest6.c | 76 +++++++++ test/sqlgw/Select/selecttest7.c | 87 ++++++++++ test/sqlgw/Select/selecttest8.c | 127 +++++++++++++++ test/sqlgw/Select/singleconngateway.c | 116 ++++++++++++++ test/sqlgw/Select/test001.ksh | 84 ++++++++++ test/sqlgw/Select/test002.ksh | 84 ++++++++++ test/sqlgw/Select/test003.ksh | 81 ++++++++++ test/sqlgw/Select/test004.ksh | 81 ++++++++++ test/sqlgw/Select/test005.ksh | 81 ++++++++++ test/sqlgw/Select/test006.ksh | 81 ++++++++++ test/sqlgw/Select/test007.ksh | 81 ++++++++++ test/sqlgw/Select/test008.ksh | 84 ++++++++++ test/sqlgw/Select/test009.ksh | 105 ++++++++++++ test/sqlnetwork/Jdbcnetwork/ConnTest1.java | 20 +++ test/sqlnetwork/Jdbcnetwork/ConnTest10.java | 19 +++ test/sqlnetwork/Jdbcnetwork/ConnTest11.java | 19 +++ test/sqlnetwork/Jdbcnetwork/ConnTest12.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest13.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest14.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest15.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest16.java | 25 +++ test/sqlnetwork/Jdbcnetwork/ConnTest17.java | 24 +++ test/sqlnetwork/Jdbcnetwork/ConnTest18.java | 24 +++ test/sqlnetwork/Jdbcnetwork/ConnTest19.java | 26 +++ test/sqlnetwork/Jdbcnetwork/ConnTest2.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest20.java | 23 +++ test/sqlnetwork/Jdbcnetwork/ConnTest3.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest4.java | 19 +++ test/sqlnetwork/Jdbcnetwork/ConnTest5.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest6.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest7.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest8.java | 18 +++ test/sqlnetwork/Jdbcnetwork/ConnTest9.java | 18 +++ test/sqlnetwork/Jdbcnetwork/Makefile | 13 ++ test/sqlnetwork/Jdbcnetwork/StmtTest1.java | 87 ++++++++++ test/sqlnetwork/Jdbcnetwork/StmtTest10.java | 91 +++++++++++ test/sqlnetwork/Jdbcnetwork/StmtTest11.java | 53 ++++++ test/sqlnetwork/Jdbcnetwork/StmtTest12.java | 99 ++++++++++++ test/sqlnetwork/Jdbcnetwork/StmtTest13.java | 58 +++++++ test/sqlnetwork/Jdbcnetwork/StmtTest2.java | 61 +++++++ test/sqlnetwork/Jdbcnetwork/StmtTest3.java | 63 ++++++++ test/sqlnetwork/Jdbcnetwork/StmtTest4.java | 19 +++ test/sqlnetwork/Jdbcnetwork/StmtTest5.java | 57 +++++++ test/sqlnetwork/Jdbcnetwork/StmtTest6.java | 63 ++++++++ test/sqlnetwork/Jdbcnetwork/StmtTest7.java | 93 +++++++++++ test/sqlnetwork/Jdbcnetwork/StmtTest8.java | 64 ++++++++ test/sqlnetwork/Jdbcnetwork/StmtTest9.java | 93 +++++++++++ test/sqlnetwork/Jdbcnetwork/test001.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test002.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test003.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test004.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test005.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test006.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test007.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test008.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test009.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test010.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test011.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test012.ksh | 16 ++ test/sqlnetwork/Jdbcnetwork/test013.ksh | 16 ++ test/sqlnetwork/Jdbcnetwork/test014.ksh | 16 ++ test/sqlnetwork/Jdbcnetwork/test015.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test016.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test017.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test018.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test019.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test020.ksh | 16 ++ test/sqlnetwork/Jdbcnetwork/test021.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test022.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test023.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test024.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test025.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test026.ksh | 16 ++ test/sqlnetwork/Jdbcnetwork/test027.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test028.ksh | 15 ++ test/sqlnetwork/Jdbcnetwork/test029.ksh | 16 ++ test/sqlnetwork/Jdbcnetwork/test030.ksh | 19 +++ test/sqlnetwork/Jdbcnetwork/test031.ksh | 16 ++ test/sqlnetwork/Jdbcnetwork/test032.ksh | 17 ++ test/sqlnetwork/Jdbcnetwork/test033.ksh | 19 +++ 114 files changed, 5994 insertions(+) create mode 100644 test/sqlgw/Makefile create mode 100644 test/sqlgw/Parameter/Makefile create mode 100644 test/sqlgw/Parameter/README create mode 100644 test/sqlgw/Parameter/common.h create mode 100644 test/sqlgw/Parameter/csql.conf create mode 100644 test/sqlgw/Parameter/exp.test001.ksh create mode 100644 test/sqlgw/Parameter/exp.test002.ksh create mode 100644 test/sqlgw/Parameter/exp.test003.ksh create mode 100644 test/sqlgw/Parameter/exp.test004.ksh create mode 100644 test/sqlgw/Parameter/exp.test005.ksh create mode 100644 test/sqlgw/Parameter/exp.test006.ksh create mode 100644 test/sqlgw/Parameter/paratest1.c create mode 100644 test/sqlgw/Parameter/paratest2.c create mode 100644 test/sqlgw/Parameter/paratest3.c create mode 100644 test/sqlgw/Parameter/paratest4.c create mode 100644 test/sqlgw/Parameter/paratest5.c create mode 100644 test/sqlgw/Parameter/paratest6.c create mode 100755 test/sqlgw/Parameter/test001.ksh create mode 100755 test/sqlgw/Parameter/test002.ksh create mode 100755 test/sqlgw/Parameter/test003.ksh create mode 100755 test/sqlgw/Parameter/test004.ksh create mode 100755 test/sqlgw/Parameter/test005.ksh create mode 100755 test/sqlgw/Parameter/test006.ksh create mode 100644 test/sqlgw/Select/Makefile create mode 100644 test/sqlgw/Select/README create mode 100644 test/sqlgw/Select/common.h create mode 100644 test/sqlgw/Select/csql.conf create mode 100644 test/sqlgw/Select/exp.test009.ksh create mode 100644 test/sqlgw/Select/exp.test009.ksh.psql create mode 100644 test/sqlgw/Select/selecttest1.c create mode 100644 test/sqlgw/Select/selecttest2.c create mode 100644 test/sqlgw/Select/selecttest3.c create mode 100644 test/sqlgw/Select/selecttest4.c create mode 100644 test/sqlgw/Select/selecttest5.c create mode 100644 test/sqlgw/Select/selecttest6.c create mode 100644 test/sqlgw/Select/selecttest7.c create mode 100644 test/sqlgw/Select/selecttest8.c create mode 100644 test/sqlgw/Select/singleconngateway.c create mode 100755 test/sqlgw/Select/test001.ksh create mode 100755 test/sqlgw/Select/test002.ksh create mode 100755 test/sqlgw/Select/test003.ksh create mode 100755 test/sqlgw/Select/test004.ksh create mode 100755 test/sqlgw/Select/test005.ksh create mode 100755 test/sqlgw/Select/test006.ksh create mode 100755 test/sqlgw/Select/test007.ksh create mode 100755 test/sqlgw/Select/test008.ksh create mode 100755 test/sqlgw/Select/test009.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/ConnTest1.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest10.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest11.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest12.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest13.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest14.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest15.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest16.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest17.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest18.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest19.java create mode 100755 test/sqlnetwork/Jdbcnetwork/ConnTest2.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest20.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest3.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest4.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest5.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest6.java create mode 100755 test/sqlnetwork/Jdbcnetwork/ConnTest7.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest8.java create mode 100644 test/sqlnetwork/Jdbcnetwork/ConnTest9.java create mode 100644 test/sqlnetwork/Jdbcnetwork/Makefile create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest1.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest10.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest11.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest12.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest13.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest2.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest3.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest4.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest5.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest6.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest7.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest8.java create mode 100644 test/sqlnetwork/Jdbcnetwork/StmtTest9.java create mode 100755 test/sqlnetwork/Jdbcnetwork/test001.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test002.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test003.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test004.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test005.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test006.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test007.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test008.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test009.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test010.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test011.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test012.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test013.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test014.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test015.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test016.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test017.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test018.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test019.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test020.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test021.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test022.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test023.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test024.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test025.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test026.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test027.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test028.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test029.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test030.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test031.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test032.ksh create mode 100755 test/sqlnetwork/Jdbcnetwork/test033.ksh diff --git a/test/sqlgw/Makefile b/test/sqlgw/Makefile new file mode 100644 index 00000000..8b8aa8e0 --- /dev/null +++ b/test/sqlgw/Makefile @@ -0,0 +1,18 @@ +OSNAME = $(shell uname -s) +MAKE=gmake + +all: + @for i in *; \ + do \ + if [ -d $$i ];\ + then cd $$i; $(MAKE); cd ..;\ + fi;\ + done + +clean: + @for i in *; \ + do \ + if [ -d $$i ];\ + then cd $$i; $(MAKE) clean; cd ..;\ + fi;\ + done diff --git a/test/sqlgw/Parameter/Makefile b/test/sqlgw/Parameter/Makefile new file mode 100644 index 00000000..8cfb7810 --- /dev/null +++ b/test/sqlgw/Parameter/Makefile @@ -0,0 +1,50 @@ +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/install/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsqlgw -lcsqlnw -lcsqlodbcadapter -lcsqlsqlnw -lcacheload -lcsql -lcsqlsql -lcsqlsqllog + +TARGETS = \ + paratest1 paratest2 paratest3 paratest4 paratest5 paratest6 + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +paratest1:paratest1.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +paratest2:paratest2.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +paratest3:paratest3.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +paratest4:paratest4.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +paratest5:paratest5.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +paratest6:paratest6.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) + +clean: + rm -f *.o ${TARGETS} diff --git a/test/sqlgw/Parameter/README b/test/sqlgw/Parameter/README new file mode 100644 index 00000000..909b4ec3 --- /dev/null +++ b/test/sqlgw/Parameter/README @@ -0,0 +1,15 @@ +This module runs SQLGwTest cases for parameterized statements. + +All the ksh scripts first create the table in target database. +The table so created is cached into the csql database cache. +The binary executable is run under this script corresponding to the script. +once executable is run the results are compared with the expected file. +The cached table is unloaded. + +VALGRIND can also be run on each of the executable for LEAK Checks by setting +an environmental variable VALGRIND to true and run the script. + +$ export VALGRIND=true +$ testXXX.ksh + +An output file testXXX.ksh.valgr is created for leak reference. diff --git a/test/sqlgw/Parameter/common.h b/test/sqlgw/Parameter/common.h new file mode 100644 index 00000000..c859e44d --- /dev/null +++ b/test/sqlgw/Parameter/common.h @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +AbsSqlConnection *createConnection() +{ +#ifdef NETWORK + AbsSqlConnection *con = SqlFactory::createConnection(CSqlNetwork); + SqlNwConnection *conn = (SqlNwConnection *) con; + conn->setHost("localhost", 5678); +#elif defined NETWORKADAPTER + AbsSqlConnection *con = SqlFactory::createConnection(CSqlNetworkAdapter); + SqlNwConnection *conn = (SqlNwConnection *) con; + conn->setHost("localhost", 5678); +#elif defined NETWORKGATEWAY + AbsSqlConnection *con = SqlFactory::createConnection(CSqlNetworkGateway); + SqlNwConnection *conn = (SqlNwConnection *) con; + conn->setHost("localhost", 5678); +#elif defined GATEWAY + AbsSqlConnection *con = SqlFactory::createConnection(CSqlGateway); +#else + AbsSqlConnection *con = SqlFactory::createConnection(CSqlAdapter); +#endif + return con; +} + +AbsSqlStatement *createStatement() +{ +#ifdef NETWORK + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlNetwork); +#elif defined NETWORKADAPTER + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlNetworkAdapter); +#elif defined NETWORKGATEWAY + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlNetworkGateway); +#elif defined GATEWAY + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlGateway); +#else + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlAdapter); +#endif + return stmt; +} diff --git a/test/sqlgw/Parameter/csql.conf b/test/sqlgw/Parameter/csql.conf new file mode 100644 index 00000000..a2cd9ffa --- /dev/null +++ b/test/sqlgw/Parameter/csql.conf @@ -0,0 +1,110 @@ +# CSQL System Configuration File + +#####################################Server Section######################## +#Important: For Server section parameters, make sure that the value is same for the +# server process and all the csql client process which connects to it. otherwise, +# behavior is undefined + +# Page size. Each database is logically divided into pages and allocation happens +# in this unit of pages. Increasing this value will reduce frequent allocation of pages. +PAGE_SIZE= 8192 + +#Total number of client process which can connect and work with the +# database concurrently +MAX_PROCS = 100 + +# Maximum size of the system database. +MAX_SYS_DB_SIZE=1048576 + +#Maximum size of the user database file. +MAX_DB_SIZE=10485760 + +#Shared memory key to be used by the system to create and locate system database. +SYS_DB_KEY=4567 + +#Shared memory key to be used by the system to create and locate user database. +USER_DB_KEY=5678 + +#Log level 0->no logging 1->Fine 2->Finer 3->Finest +LOG_LEVEL=0 + +#Give full path for the log file where important system actions are stored. +LOG_FILE=/tmp/csql/log/log.out + +#The virtual memory start address at which the shared memory segment +# will be created and attached. +MAP_ADDRESS=400000000 + +# Whether to enable durability +DURABILITY=false + +# Can be set true only when DURABILITY is true +MMAP=false + +#Give full path for the database file where table and record information will +#be stored for durability +DATABASE_FILE=/tmp/csql/db + +#Important: For Server section parameters, make sure that the value is same for the +# server process and all the csql client process which connects to it. otherwise, +# behavior is undefined +#####################################Client Section######################## + +#Mutex timeout interval seconds +MUTEX_TIMEOUT_SECS=0 +MUTEX_TIMEOUT_USECS=5000 +MUTEX_TIMEOUT_RETRIES=10 + +#Lock timeout interval seconds +LOCK_TIMEOUT_SECS=0 +LOCK_TIMEOUT_USECS=5000 +LOCK_TIMEOUT_RETRIES=10 + +#####################################Cache Section######################## + +#Whether to enable caching of tables from target database +CACHE_TABLE=true + +#Set cache id for multiple bidirectional cache node for single data source +SITE_ID=1 + +#DSN Name to connect to the target database. +#This should be present in ~/odbc.ini file +DSN=myodbc3 + +# Whethere to enable bidirectional updates for cached tables. +ENABLE_BIDIRECTIONAL_CACHE=false + +CACHE_RECEIVER_WAIT_SECS=10 + +#Mode of operation SYNC or ASYNC +CACHE_MODE=SYNC + +##########################SqlNetworkServer Section######################## + +# Whether to enable SqlNetwork server +CSQL_SQL_SERVER=false + +#Set port for Network access +PORT=5678 + +#Whether to enable Replication across the sites +REPLICATION=false + +#No of sites to replicate +REPLICATION_SITES=16 + +#Give full path for the file where all the table information is stored +TABLE_CONFIG_FILE=/tmp/csql/csqltable.conf + +#Give full path of the file where all the DSN information is stored +DS_CONFIG_FILE=/tmp/csql/csqlds.conf + +#Give full path for the file where all the peer site information is stored +NETWORK_CONFIG_FILE=/tmp/csql/csqlnw.conf + +# MSGKEY for creating msg queue for MsgQueue Server +MSG_KEY=2530 + +ID_SHM_KEY=1950 +#####################################End Section######################## diff --git a/test/sqlgw/Parameter/exp.test001.ksh b/test/sqlgw/Parameter/exp.test001.ksh new file mode 100644 index 00000000..31c81174 --- /dev/null +++ b/test/sqlgw/Parameter/exp.test001.ksh @@ -0,0 +1,123 @@ +noOfParamField Returns=10 + +*********************************************** +0 FIELD INFORMATION :: +Field Name :f1 +Data type of the field :0 +length of the field :4 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +1 FIELD INFORMATION :: +Field Name :f2 +Data type of the field :3 +length of the field :4 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +2 FIELD INFORMATION :: +Field Name :f3 +Data type of the field :30 +length of the field :32 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +3 FIELD INFORMATION :: +Field Name :f4 +Data type of the field :11 +length of the field :4 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +4 FIELD INFORMATION :: +Field Name :f5 +Data type of the field :11 +length of the field :4 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +5 FIELD INFORMATION :: +Field Name :f6 +Data type of the field :20 +length of the field :4 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +6 FIELD INFORMATION :: +Field Name :f7 +Data type of the field :21 +length of the field :4 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +7 FIELD INFORMATION :: +Field Name :f8 +Data type of the field :22 +length of the field :8 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +8 FIELD INFORMATION :: +Field Name :f9 +Data type of the field :0 +length of the field :4 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** + +*********************************************** +9 FIELD INFORMATION :: +Field Name :f10 +Data type of the field :2 +length of the field :8 +Offset :0 +Default value : +Null field :0 +Default value :0 +*********************************************** +Total rows inserted 10 +f1=0 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=1 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=2 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=3 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=4 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=5 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=6 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=7 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=8 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +f1=9 | f2=10 | f3=jitendra | f4=5.500000 | f5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | f9=20 | f10=12000 +Total row fetched=10 diff --git a/test/sqlgw/Parameter/exp.test002.ksh b/test/sqlgw/Parameter/exp.test002.ksh new file mode 100644 index 00000000..6ba3785d --- /dev/null +++ b/test/sqlgw/Parameter/exp.test002.ksh @@ -0,0 +1,12 @@ +Total rows inserted 10 +F1=101 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=102 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=103 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=104 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=105 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=106 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=107 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=108 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=109 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=110 | F2=10 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +10 Tuples fetched diff --git a/test/sqlgw/Parameter/exp.test003.ksh b/test/sqlgw/Parameter/exp.test003.ksh new file mode 100644 index 00000000..b58d1c51 --- /dev/null +++ b/test/sqlgw/Parameter/exp.test003.ksh @@ -0,0 +1,8 @@ +Total rows inserted 10 +Total row deleted=5 +F1=0 | F2=1 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=1 | F2=1 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=2 | F2=1 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=3 | F2=1 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +F1=4 | F2=1 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2007-1-21 | TIME=12:29:30 | TIMESTAMP=2007-1-21 12:29:30 | F9=20 | F10=12000 +Total row fetched=5 diff --git a/test/sqlgw/Parameter/exp.test004.ksh b/test/sqlgw/Parameter/exp.test004.ksh new file mode 100644 index 00000000..9684d25b --- /dev/null +++ b/test/sqlgw/Parameter/exp.test004.ksh @@ -0,0 +1,15 @@ +10 Rows inserted +noOfParamFields return=7 +5 Rows updated +F1=0 | F2=11 | F3=lakshya | F4=11.220000 | F5=20.250000 | DATE=2007-3-30 | TIME=12:29:30 | TIMESTAMP=2007-3-30 10:25:55 | F9=20 | F10=15000 +F1=1 | F2=12 | F3=lakshya | F4=11.220000 | F5=20.250000 | DATE=2007-3-30 | TIME=12:29:30 | TIMESTAMP=2007-3-30 10:25:55 | F9=20 | F10=15000 +F1=2 | F2=13 | F3=lakshya | F4=11.220000 | F5=20.250000 | DATE=2007-3-30 | TIME=12:29:30 | TIMESTAMP=2007-3-30 10:25:55 | F9=20 | F10=15000 +F1=3 | F2=14 | F3=lakshya | F4=11.220000 | F5=20.250000 | DATE=2007-3-30 | TIME=12:29:30 | TIMESTAMP=2007-3-30 10:25:55 | F9=20 | F10=15000 +F1=4 | F2=15 | F3=lakshya | F4=11.220000 | F5=20.250000 | DATE=2007-3-30 | TIME=12:29:30 | TIMESTAMP=2007-3-30 10:25:55 | F9=20 | F10=15000 + +F1=5 | F2=16 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2008-1-21 | TIME=12:29:30 | TIMESTAMP=2008-1-21 12:29:30 | F9=20 | F10=12000 +F1=6 | F2=17 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2008-1-21 | TIME=12:29:30 | TIMESTAMP=2008-1-21 12:29:30 | F9=20 | F10=12000 +F1=7 | F2=18 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2008-1-21 | TIME=12:29:30 | TIMESTAMP=2008-1-21 12:29:30 | F9=20 | F10=12000 +F1=8 | F2=19 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2008-1-21 | TIME=12:29:30 | TIMESTAMP=2008-1-21 12:29:30 | F9=20 | F10=12000 +F1=9 | F2=20 | F3=jitendra | F4=5.500000 | F5=10.500000 | DATE=2008-1-21 | TIME=12:29:30 | TIMESTAMP=2008-1-21 12:29:30 | F9=20 | F10=12000 +10 Rows fetched diff --git a/test/sqlgw/Parameter/exp.test005.ksh b/test/sqlgw/Parameter/exp.test005.ksh new file mode 100644 index 00000000..5b5b86f9 --- /dev/null +++ b/test/sqlgw/Parameter/exp.test005.ksh @@ -0,0 +1,22 @@ +Total rows inserted 20 +F1=0 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=1 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=2 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=3 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=4 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=5 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=6 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=7 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=8 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=9 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=0 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=1 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=2 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=3 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=4 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=5 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=6 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=7 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=8 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +F1=9 | F2=1 | F3=jitendra | F4=5.500000 | F5=NULL | F6=2007-01-21 | F7=NULL | F8=2007-1-21 12:29:30 | F9=20 | F10=12000 | +Total row fetched=20 diff --git a/test/sqlgw/Parameter/exp.test006.ksh b/test/sqlgw/Parameter/exp.test006.ksh new file mode 100644 index 00000000..ec3f3929 --- /dev/null +++ b/test/sqlgw/Parameter/exp.test006.ksh @@ -0,0 +1,14 @@ +10 Rows inserted +noOfParamFields return=7 +5 Rows updated +F1=0 | F2=11 | F3=NULL | F4=11.220000 | F5=20.250000 | F6=NULL | F7=12:29:30 | F8=2007-3-30 10:25:55 | F9=20 | F10=15000 | +F1=1 | F2=12 | F3=NULL | F4=11.220000 | F5=20.250000 | F6=NULL | F7=12:29:30 | F8=2007-3-30 10:25:55 | F9=20 | F10=15000 | +F1=2 | F2=13 | F3=NULL | F4=11.220000 | F5=20.250000 | F6=NULL | F7=12:29:30 | F8=2007-3-30 10:25:55 | F9=20 | F10=15000 | +F1=3 | F2=14 | F3=NULL | F4=11.220000 | F5=20.250000 | F6=NULL | F7=12:29:30 | F8=2007-3-30 10:25:55 | F9=20 | F10=15000 | +F1=4 | F2=15 | F3=NULL | F4=11.220000 | F5=20.250000 | F6=NULL | F7=12:29:30 | F8=2007-3-30 10:25:55 | F9=20 | F10=15000 | +F1=5 | F2=16 | F3=jitendra | F4=5.500000 | F5=10.500000 | F6=2008-01-21 | F7=12:29:30 | F8=2008-1-21 12:29:30 | F9=20 | F10=12000 | +F1=6 | F2=17 | F3=jitendra | F4=5.500000 | F5=10.500000 | F6=2008-01-21 | F7=12:29:30 | F8=2008-1-21 12:29:30 | F9=20 | F10=12000 | +F1=7 | F2=18 | F3=jitendra | F4=5.500000 | F5=10.500000 | F6=2008-01-21 | F7=12:29:30 | F8=2008-1-21 12:29:30 | F9=20 | F10=12000 | +F1=8 | F2=19 | F3=jitendra | F4=5.500000 | F5=10.500000 | F6=2008-01-21 | F7=12:29:30 | F8=2008-1-21 12:29:30 | F9=20 | F10=12000 | +F1=9 | F2=20 | F3=jitendra | F4=5.500000 | F5=10.500000 | F6=2008-01-21 | F7=12:29:30 | F8=2008-1-21 12:29:30 | F9=20 | F10=12000 | +Rows fetched=10 diff --git a/test/sqlgw/Parameter/paratest1.c b/test/sqlgw/Parameter/paratest1.c new file mode 100644 index 00000000..5a7e106f --- /dev/null +++ b/test/sqlgw/Parameter/paratest1.c @@ -0,0 +1,194 @@ +/* create table t1 with 10 fields. + * insert some records into it. + * noOfParamFields() should return 10. + * getParamFldInfo() for all fields and print the field info. + * select * from t1; + + * Author : Jitendra Lenka. + */ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con= createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows = 0; + // insert into table + int para=0; + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + para=8; + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + para=9; + } + else{ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + para=9; + } + int f1var = 100; + short int f2var = 10; + char f3var[32]="jitendra"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2007,01,21); + + Time f7var; + f7var.set(12,29,30); + + TimeStamp f8var; + f8var.setDate(2007,01,21); + f8var.setTime(12,29,30); + + int f9var = 20; + long long f10var = 12000; + + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 4; + } +//****************************************************************************** + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + int nop; + nop = stmt->noOfParamFields(); + printf("noOfParamField Returns=%d\n",nop); + + + //getParamFldInfo() + FieldInfo *field = new FieldInfo(); + + + char fldName[20]; + DataType type; + size_t length; + int offset; + char defaultValueBuf[10]; + bool isNull; + bool isDefault; + + for(int i=0;igetParamFldInfo(i+1,field); + if(rv!=OK)return 1; + printf("Field Name :%s\n", field->fldName); + printf("Data type of the field :%d\n",field->type); + printf("length of the field :%d\n",field->length); + printf("Offset :%d\n",field->offset); + printf("Default value :%s\n",field->defaultValueBuf); + printf("Null field :%d\n",field->isNull); + printf("Default value :%d\n",field->isDefault); + printf("***********************************************\n"); + } + delete field; + int count=0; + + for(int i=0;i<10;i++) + { + rv = con->beginTrans(); + if(rv!=OK) break; + f1var=i; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setFloatParam(5,f5var); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setTimeParam(7,f7var); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("Total rows inserted %d\n",count); + + stmt->free(); + + //********************************************************** + + // SELECT * FROM t1; + + strcpy(statement,"SELECT * FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"SELECT * FROM t1"); + } + + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 5; + } + + stmt->bindField(1,&f1var); + stmt->bindField(2,&f2var); + stmt->bindField(3,f3var); + stmt->bindField(4,&f4var); + stmt->bindField(5,&f5var); + stmt->bindField(6,&f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->bindField(7,&f8var); + stmt->bindField(8,&f9var); + stmt->bindField(9,&f10var); + + }else{ + stmt->bindField(7,&f7var); + stmt->bindField(8,&f8var); + stmt->bindField(9,&f9var); + stmt->bindField(10,&f10var); + } + + count=0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + while(stmt->fetch() !=NULL) + { + if(strcmp(getenv("DSN"),"oracle")==0) + printf("f1=%d | f2=%hd | f3=%s | f4=%f | f5=%f | DATE=%d-%d-%d | TIMESTAMP=%d-%d-%d %d:%d:%d | f9=%d | f10=%lld\n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + else + printf("f1=%d | f2=%hd | f3=%s | f4=%f | f5=%f | DATE=%d-%d-%d | TIME=%d:%d:%d | TIMESTAMP=%d-%d-%d %d:%d:%d | f9=%d | f10=%lld\n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f7var.hours(),f7var.minutes(),f7var.seconds(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + count++; + } + + stmt->close(); + rv = con->commit(); + if(rv !=OK) + { + delete stmt; + delete con; + return 7; + } + + printf("Total row fetched=%d\n",count); + + stmt->free(); + delete stmt; + delete con; + return 0; +} diff --git a/test/sqlgw/Parameter/paratest2.c b/test/sqlgw/Parameter/paratest2.c new file mode 100644 index 00000000..9974b642 --- /dev/null +++ b/test/sqlgw/Parameter/paratest2.c @@ -0,0 +1,194 @@ +/* create table T1 with 10 fields. + * insert some records into it. + * select * from T1 with where clause; +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con= createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows = 0; + + // insert into table + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + } + else{ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + } + + int f1var = 100; + short int f2var = 10; + char f3var[35]="jitendra"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2007,01,21); + + Time f7var; + f7var.set(12,29,30); + + TimeStamp f8var; + f8var.setDate(2007,01,21); + f8var.setTime(12,29,30); + + int f9var = 20; + long long f10var = 12000; + + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 3; + } + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + + int count=0; + + for(int i=0;i<10;i++) + { + rv = con->beginTrans(); + if(rv!=OK) break; + f1var++; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setFloatParam(5,f5var); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setTimeParam(7,f7var); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("Total rows inserted %d\n",count); + + + stmt->free(); + + //********************************************************** + + // SELECT * FROM T1; + if(strcmp(getenv("DSN"),"oracle")==0) + strcpy(statement,"SELECT * FROM t1 WHERE f1=? AND f2=? AND f3=? AND f4=? AND f5=? AND f6=? AND f8=? AND f9=? AND f10=?;"); + else if(strcmp(getenv("DSN"),"sybase")==0) + strcpy(statement,"SELECT * FROM t1 WHERE f1=? AND f2=? AND f3=? AND f4=? AND f5=? AND f6=? AND f7=? AND f8=? AND f9=? AND f10=?;"); + else if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT * FROM t1 WHERE f1=? AND f2=? AND f3=? AND f4=? AND f5=? AND f6=? AND f7=? AND f8=? AND f9=? AND f10=?"); + else + strcpy(statement,"SELECT * FROM t1 WHERE f1=? AND f2=? AND f3=? AND f4=? AND f5=? AND f6=? AND f7=? AND f8=? AND f9=? AND f10=?;"); + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 4; + } + + stmt->bindField(1,&f1var); + stmt->bindField(2,&f2var); + stmt->bindField(3,f3var); + stmt->bindField(4,&f4var); + stmt->bindField(5,&f5var); + stmt->bindField(6,&f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->bindField(7,&f8var); + stmt->bindField(8,&f9var); + stmt->bindField(9,&f10var); + + }else{ + stmt->bindField(7,&f7var); + stmt->bindField(8,&f8var); + stmt->bindField(9,&f9var); + stmt->bindField(10,&f10var); + } + + int f1var1=100; + short int f2var1=10; + char f3var1[35]="jitendra"; + float f4var1=5.5; + float f5var1=10.50; + Date f6var1; + f6var1.set(2007,01,21); + + Time f7var1; + f7var1.set(12,29,30); + + TimeStamp f8var1; + f8var1.setDate(2007,01,21); + f8var1.setTime(12,29,30); + + int f9var1=20; + long long f10var1=12000; + count=0; + for(int i=0;i<10;i++) + { + rv = con->beginTrans(); + if(rv!=OK)break; + + f1var1++; + stmt->setIntParam(1,f1var1); + stmt->setShortParam(2,f2var1); + stmt->setStringParam(3,f3var1); + stmt->setFloatParam(4,f4var1); + stmt->setFloatParam(5,f5var1); + stmt->setDateParam(6,f6var1); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var1); + stmt->setIntParam(8,f9var1); + stmt->setLongLongParam(9,f10var1); + }else{ + stmt->setTimeParam(7,f7var1); + stmt->setTimeStampParam(8,f8var1); + stmt->setIntParam(9,f9var1); + stmt->setLongLongParam(10,f10var1); + } + + + stmt->execute(rows); + + while(stmt->fetch()!=NULL) + { + if(strcmp(getenv("DSN"),"oracle")==0) + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIMESTAMP=%d-%d-%d %d:%d:%d | F9=%d | F10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + else + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIME=%d:%d:%d | TIMESTAMP=%d-%d-%d %d:%d:%d | F9=%d | F10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f7var.hours(),f7var.minutes(),f7var.seconds(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + + count++; + } + stmt->close(); + rv = con->commit(); + if(rv!=OK)return 5; + } + stmt->free(); + + printf("%d Tuples fetched\n",count); + delete stmt; + delete con; + return 0; +} diff --git a/test/sqlgw/Parameter/paratest3.c b/test/sqlgw/Parameter/paratest3.c new file mode 100644 index 00000000..b967e861 --- /dev/null +++ b/test/sqlgw/Parameter/paratest3.c @@ -0,0 +1,240 @@ +/* create table T1 with 10 fields. + * insert some records into it. + * delete records from T1 with where clause + * select * from T1; +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows = 0; + // insert into table + + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + } + else{ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + } + + int f1var = 0; + short int f2var = 1; + char f3var[35]="jitendra"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2007,01,21); + + Time f7var; + f7var.set(12,29,30); + + TimeStamp f8var; + f8var.setDate(2007,01,21); + f8var.setTime(12,29,30); + + int f9var = 20; + long long f10var = 12000; + + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 4; + } + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + + int count=0; + + for(int i=0;i<10;i++) + { + rv = con->beginTrans(); + if(rv!=OK) break; + f1var=i; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setFloatParam(5,f5var); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setTimeParam(7,f7var); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("Total rows inserted %d\n",count); + + + stmt->free(); + //********************************************************* + + // delete records from the T1 + if(strcmp(getenv("DSN"),"oracle")==0) + strcpy(statement,"DELETE FROM t1 WHERE f10=? AND f9=? AND f8=? AND f6=? AND f5=? AND f4=? AND f3=? AND f2=? AND f1=?;"); + else if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"DELETE FROM t1 WHERE f10=? AND f9=? AND f8=? AND f7=? AND f6=? AND f5=? AND f4=? AND f3=? AND f2=? AND f1=?"); + else + strcpy(statement,"DELETE FROM t1 WHERE f10=? AND f9=? AND f8=? AND f7=? AND f6=? AND f5=? AND f4=? AND f3=? AND f2=? AND f1=?;"); + + rv = stmt->prepare(statement); + if(rv!=OK){delete stmt;delete con;return -1;} + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + + /* stmt->bindField(1,&f10var); + stmt->bindField(2,&f9var); + stmt->bindField(3,&f8var); + stmt->bindField(4,&f7var); + stmt->bindField(5,&f6var); + stmt->bindField(6,&f5var); + stmt->bindField(7,&f4var); + stmt->bindField(8,f3var); + stmt->bindField(9,&f2var); + stmt->bindField(10,&f1var);*/ + + short int f2var1=1; + char f3var1[20] ="jitendra"; + float f4var1 = 5.5; + float f5var1 = 10.50; + Date f6var1; + f6var1.set(2007,1,21); + + Time f7var1; + f7var1.set(12,29,30); + + TimeStamp f8var1; + f8var1.setDate(2007,1,21); + f8var1.setTime(12,29,30); + + int f9var1=20; + long long f10var1=12000; + count=0; + + for(int i=5;i<10;i++) + { + rv = con->beginTrans(); + if(rv!=OK)break; + + stmt->setLongLongParam(1,f10var1); + stmt->setIntParam(2,f9var1); + stmt->setTimeStampParam(3,f8var1); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setDateParam(4,f6var1); + stmt->setFloatParam(5,f5var1); + stmt->setFloatParam(6,f4var1); + stmt->setStringParam(7,f3var1); + stmt->setShortParam(8,f2var1); + stmt->setIntParam(9,i); + }else{ + stmt->setTimeParam(4,f7var1); + stmt->setDateParam(5,f6var1); + stmt->setFloatParam(6,f5var1); + stmt->setFloatParam(7,f4var1); + stmt->setStringParam(8,f3var1); + stmt->setShortParam(9,f2var1); + stmt->setIntParam(10,i); + + } + + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + stmt->free(); + printf("Total row deleted=%d\n",count); + + + + + //********************************************************** + + // SELECT * FROM T1; + strcpy(statement,"SELECT * FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"SELECT * FROM t1"); + } + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 5; + } + + stmt->bindField(1,&f1var); + stmt->bindField(2,&f2var); + stmt->bindField(3,f3var); + stmt->bindField(4,&f4var); + stmt->bindField(5,&f5var); + stmt->bindField(6,&f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->bindField(7,&f8var); + stmt->bindField(8,&f9var); + stmt->bindField(9,&f10var); + + }else{ + stmt->bindField(7,&f7var); + stmt->bindField(8,&f8var); + stmt->bindField(9,&f9var); + stmt->bindField(10,&f10var); + } + count=0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + while(stmt->fetch() !=NULL) + { + if(strcmp(getenv("DSN"),"oracle")==0) + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIMESTAMP=%d-%d-%d %d:%d:%d | F9=%d | F10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + else + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIME=%d:%d:%d | TIMESTAMP=%d-%d-%d %d:%d:%d | F9=%d | F10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f7var.hours(),f7var.minutes(),f7var.seconds(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + + count++; + } + + stmt->close(); + rv = con->commit(); + if(rv !=OK) + { + delete stmt; + delete con; + return 7; + } + + printf("Total row fetched=%d\n",count); + stmt->free(); + + delete stmt; + delete con; + return 0; +} diff --git a/test/sqlgw/Parameter/paratest4.c b/test/sqlgw/Parameter/paratest4.c new file mode 100644 index 00000000..683e099c --- /dev/null +++ b/test/sqlgw/Parameter/paratest4.c @@ -0,0 +1,219 @@ +/* create table T1 with 10 fields. + * insert some records into it. + * update T1 WITH ALL 7 PARAMETERS. + noOfParamFields() should return 7. + * select * from T1; +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows = 0; + + // insert into table + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + } + else{ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + } + + int f1var = 0; + short int f2var = 10; + char f3var[35]="jitendra"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2008,01,21); + + Time f7var; + f7var.set(12,29,30); + + TimeStamp f8var; + f8var.setDate(2008,01,21); + f8var.setTime(12,29,30); + + int f9var = 20; + long long f10var = 12000; + + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 3; + } + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + + int count=0; + + for(int i=0;i<10;i++) + { + rv = con->beginTrans(); + if(rv!=OK) break; + f1var=i; + f2var++; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setFloatParam(5,f5var); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setTimeParam(7,f7var); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("%d Rows inserted \n",count); + + + stmt->free(); + + //********************************************************** + // UPDATE TABLE + + strcpy(statement,"UPDATE t1 SET f10=?,f8=?,f6=?,f5=?,f4=?,f3=? WHERE f1=?;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"UPDATE t1 SET f10=?,f8=?,f6=?,f5=?,f4=?,f3=? WHERE f1=?"); + rv = stmt->prepare(statement); + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + + int nop; + nop = stmt->noOfParamFields(); + printf("noOfParamFields return=%d\n",nop); + if(nop!=7)return 4; + + long long f10var1=15000; + TimeStamp f8var1; + f8var1.setDate(2007,3,30); + f8var1.setTime(10,25,55); + + Date f6var1; + f6var1.set(2007,3,30); + + float f5var1=20.25; + float f4var1=11.22; + char f3var1[10]="lakshya"; + + int f1var1; + count=0; + + for(int i=0;i<5;i++) + { + + rv = con->beginTrans(); + if(rv!=OK)break; + + f1var1=i; + stmt->setIntParam(7,f1var1); + stmt->setLongLongParam(1,f10var1); + stmt->setTimeStampParam(2,f8var1); + stmt->setDateParam(3,f6var1); + stmt->setFloatParam(4,f5var1); + stmt->setFloatParam(5,f4var1); + stmt->setStringParam(6,f3var1); + + //stmt->setShortParam(7,f2var1); + + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + + stmt->free(); + + printf("%d Rows updated\n",count); + + //********************************************************** + // SELECT * FROM T1; + + strcpy(statement,"SELECT * FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT * FROM t1"); + rv = stmt->prepare(statement); + if(rv!=OK) + { + delete stmt; + delete con; + return 5; + } + + stmt->bindField(1,&f1var); + stmt->bindField(2,&f2var); + stmt->bindField(3,f3var); + stmt->bindField(4,&f4var); + stmt->bindField(5,&f5var); + stmt->bindField(6,&f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->bindField(7,&f8var); + stmt->bindField(8,&f9var); + stmt->bindField(9,&f10var); + + }else{ + stmt->bindField(7,&f7var); + stmt->bindField(8,&f8var); + stmt->bindField(9,&f9var); + stmt->bindField(10,&f10var); + } + + count=0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + while(stmt->fetch() !=NULL) + { + if(f1var==5)printf("\n"); + if(strcmp(getenv("DSN"),"oracle")==0) + printf("f1=%d | f2=%hd | f3=%s | f4=%f | f5=%f | DATE=%d-%d-%d | TIMESTAMP=%d-%d-%d %d:%d:%d | f9=%d | f10=%lld\n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + else + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIME=%d:%d:%d | TIMESTAMP=%d-%d-%d %d:%d:%d | F9=%d | F10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f7var.hours(),f7var.minutes(),f7var.seconds(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + + + count++; + } + + stmt->close(); + rv = con->commit(); + if(rv !=OK) + { + delete stmt; + delete con; + return 7; + } + + printf("%d Rows fetched\n",count); + stmt->free(); + delete stmt; + delete con; + return 0; +} diff --git a/test/sqlgw/Parameter/paratest5.c b/test/sqlgw/Parameter/paratest5.c new file mode 100644 index 00000000..c9823d85 --- /dev/null +++ b/test/sqlgw/Parameter/paratest5.c @@ -0,0 +1,187 @@ +/* create table T1 with 10 fields. + * insert some records into it with null values + * delete records from T1 with where clause + * + * select * from T1; +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows = 0; + + // insert into table + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + } else { + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + } + + int f1var = 0; + short int f2var = 1; + char f3var[32]="jitendra"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2007,01,21); + Time f7var; + f7var.set(12,29,30); + TimeStamp f8var; + f8var.setDate(2007,01,21); + f8var.setTime(12,29,30); + int f9var = 20; + long long f10var = 12000; + char f11var[12]="23fe"; + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 4; } + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + int count=0; + for(int i=0;i<10;i++) { + rv = con->beginTrans(); + if(rv!=OK) break; + f1var=i; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setNull(5); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setNull(7); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + //stmt->setBinaryParam(11,f11var, 12); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + stmt->free(); + //********************************************************* + // Insert with value list records from the T1 + if(strcmp(getenv("DSN"),"oracle")==0) + strcpy(statement,"INSERT INTO t1(f1,f2,f3,f4,f5,f6,f8,f9,f10) VALUES(?,?,?,?,?,?,?,?,?);"); + else if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"INSERT INTO t1(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10) VALUES(?,?,?,?,?,?,?,?,?,?)"); + else + strcpy(statement,"INSERT INTO t1(f1,f2,f3,f4,f5,f6,f7,f8,f9,f10) VALUES(?,?,?,?,?,?,?,?,?,?);"); + + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 4; } + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + for(int i=0;i<10;i++) { + rv = con->beginTrans(); + if(rv!=OK) break; + f1var=i; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setNull(5); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setNull(7); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("Total rows inserted %d\n",count); + stmt->free(); + + //********************************************************** + // SELECT * FROM T1; + strcpy(statement,"SELECT * FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"SELECT * FROM t1"); + } + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 5; } + stmt->bindField(1,&f1var); + stmt->bindField(2,&f2var); + stmt->bindField(3,f3var); + stmt->bindField(4,&f4var); + stmt->bindField(5,&f5var); + stmt->bindField(6,&f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->bindField(7,&f8var); + stmt->bindField(8,&f9var); + stmt->bindField(9,&f10var); + + }else{ + stmt->bindField(7,&f7var); + stmt->bindField(8,&f8var); + stmt->bindField(9,&f9var); + stmt->bindField(10,&f10var); + } + //stmt->bindField(11,f11var); + count=0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + while(stmt->fetch() !=NULL) { + if(stmt->isFldNull(1)) printf("F1=NULL | "); + else printf("F1=%d | ", f1var); + if(stmt->isFldNull(2)) printf("F2=NULL | "); + else printf("F2=%hd | ", f2var); + if(stmt->isFldNull(3)) printf("F3=NULL | "); + else printf("F3=%s | ", f3var); + if(stmt->isFldNull(4)) printf("F4=NULL | "); + else printf("F4=%f | ", f4var); + if(stmt->isFldNull(5)) printf("F5=NULL | "); + else printf("F5=%f | ", f5var); + if(stmt->isFldNull(6)) printf("F6=NULL | "); + else printf("F6=%02d-%02d-%02d | ",f6var.year(), f6var.month(), f6var.dayOfMonth()); + if(strcmp(getenv("DSN"),"oracle") != 0){ + if(stmt->isFldNull(7)) printf("F7=NULL | "); + else printf("F7=%02d:%02d:%02d | ", f7var.hours(),f7var.minutes(),f7var.seconds()); + } + if(stmt->isFldNull(8)) printf("F8=NULL | "); + else printf("F8=%d-%d-%d %d:%d:%d | ", f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds()); + if(stmt->isFldNull(9)) printf("F9=NULL | "); + else printf("F9=%d | ", f9var); + if(stmt->isFldNull(10)) printf("F10=NULL | "); + else printf("F10=%lld | ", f10var); + printf("\n"); + count++; + } + stmt->close(); + rv = con->commit(); + if(rv !=OK) { delete stmt; delete con; return 7; } + printf("Total row fetched=%d\n",count); + stmt->free(); delete stmt; delete con; + return 0; +} diff --git a/test/sqlgw/Parameter/paratest6.c b/test/sqlgw/Parameter/paratest6.c new file mode 100644 index 00000000..e6e70804 --- /dev/null +++ b/test/sqlgw/Parameter/paratest6.c @@ -0,0 +1,192 @@ +/* create table T1 with 10 fields. + * insert some records into it. + * update T1 with some Null values in the parameter. + noOfParamFields() should return 8. + * select * from T1; +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + + char statement[200]; + int rows = 0; + + // insert into table + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + } + else{ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + } + + int f1var = 0; + short int f2var = 10; + char f3var[32]="jitendra"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2008,01,21); + Time f7var; + f7var.set(12,29,30); + TimeStamp f8var; + f8var.setDate(2008,01,21); + f8var.setTime(12,29,30); + int f9var = 20; + long long f10var = 12000; + char f11var[8]="23fe"; + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 4; } + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + int count=0; + for(int i=0;i<10;i++) { + rv = con->beginTrans(); + if(rv!=OK) break; + f1var=i; + f2var++; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setFloatParam(5,f5var); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setTimeParam(7,f7var); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + // stmt->setBinaryParam(11,f11var,8); + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("%d Rows inserted \n",count); + stmt->free(); + //********************************************************** + // UPDATE TABLE + strcpy(statement,"UPDATE t1 SET f10=?,f8=?,f6=?,f5=?,f4=?,f3=? WHERE f2=?;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"UPDATE t1 SET f10=?,f8=?,f6=?,f5=?,f4=?,f3=? WHERE f2=?"); + rv = stmt->prepare(statement); + if(strcmp(getenv("DSN"),"psql")==0){ + con->rollback(); + } + + int nop; + nop = stmt->noOfParamFields(); + printf("noOfParamFields return=%d\n",nop); + if(nop!=7)return 5; + long long f10var1=15000; + TimeStamp f8var1; + f8var1.setDate(2007,3,30); + f8var1.setTime(10,25,55); + Date f6var1; + f6var1.set(2007,3,30); + float f5var1=20.25; + float f4var1=11.22; + char f3var1[10]="lakshya"; + char f11var1[8]="ab12"; + short int f2var1=10; + count=0; + for(int i=0;i<5;i++) { + rv = con->beginTrans(); + if(rv!=OK)break; + f2var1++; + stmt->setShortParam(7,f2var1); + stmt->setLongLongParam(1,f10var1); + stmt->setTimeStampParam(2,f8var1); + stmt->setNull(3); + stmt->setFloatParam(4,f5var1); + stmt->setFloatParam(5,f4var1); + stmt->setNull(6); + //stmt->setBinaryParam(7,f11var1, 8); + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + stmt->free(); + printf("%d Rows updated\n",count); + //********************************************************** + // SELECT * FROM T1; + strcpy(statement,"SELECT * FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT * FROM t1"); + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 6; } + stmt->bindField(1,&f1var); + stmt->bindField(2,&f2var); + stmt->bindField(3,f3var); + stmt->bindField(4,&f4var); + stmt->bindField(5,&f5var); + stmt->bindField(6,&f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->bindField(7,&f8var); + stmt->bindField(8,&f9var); + stmt->bindField(9,&f10var); + + }else{ + stmt->bindField(7,&f7var); + stmt->bindField(8,&f8var); + stmt->bindField(9,&f9var); + stmt->bindField(10,&f10var); + } + //stmt->bindField(11,f11var); + count=0; + rv = con->beginTrans(); + if(rv!=OK)return 7; + stmt->execute(rows); + while(stmt->fetch() !=NULL) { + if(stmt->isFldNull(1)) printf("F1=NULL | "); + else printf("F1=%d | ", f1var); + if(stmt->isFldNull(2)) printf("F2=NULL | "); + else printf("F2=%hd | ", f2var); + if(stmt->isFldNull(3)) printf("F3=NULL | "); + else printf("F3=%s | ", f3var); + if(stmt->isFldNull(4)) printf("F4=NULL | "); + else printf("F4=%f | ", f4var); + if(stmt->isFldNull(5)) printf("F5=NULL | "); + else printf("F5=%f | ", f5var); + if(stmt->isFldNull(6)) printf("F6=NULL | "); + else printf("F6=%02d-%02d-%02d | ",f6var.year(), f6var.month(), f6var.dayOfMonth()); + if(strcmp(getenv("DSN"),"oracle")!=0){ + if(stmt->isFldNull(7)) printf("F7=NULL | "); + else printf("F7=%02d:%02d:%02d | ", f7var.hours(),f7var.minutes(),f7var.seconds()); + } + if(stmt->isFldNull(8)) printf("F8=NULL | "); + else printf("F8=%d-%d-%d %d:%d:%d | ", f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds()); + if(stmt->isFldNull(9)) printf("F9=NULL | "); + else printf("F9=%d | ", f9var); + if(stmt->isFldNull(10)) printf("F10=NULL | "); + else printf("F10=%lld | ", f10var); + printf("\n"); + count++; + } + stmt->close(); + rv = con->commit(); + if(rv !=OK) { delete stmt; delete con; return 8; } + printf("Rows fetched=%d\n",count); + stmt->free(); delete stmt; delete con; + return 0; +} diff --git a/test/sqlgw/Parameter/test001.ksh b/test/sqlgw/Parameter/test001.ksh new file mode 100755 index 00000000..05bf3a2f --- /dev/null +++ b/test/sqlgw/Parameter/test001.ksh @@ -0,0 +1,83 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Parameter/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Parameter +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 DATETIME,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/paratest1 2> $0.valgr +else + ${REL_PATH}/paratest1 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Parameter/test002.ksh b/test/sqlgw/Parameter/test002.ksh new file mode 100755 index 00000000..399c06f4 --- /dev/null +++ b/test/sqlgw/Parameter/test002.ksh @@ -0,0 +1,84 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Parameter/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Parameter +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 DATETIME,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/paratest2 2> $0.valgr +else + ${REL_PATH}/paratest2 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Parameter/test003.ksh b/test/sqlgw/Parameter/test003.ksh new file mode 100755 index 00000000..c731e5e0 --- /dev/null +++ b/test/sqlgw/Parameter/test003.ksh @@ -0,0 +1,84 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Parameter/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Parameter +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 DATETIME,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/paratest3 2> $0.valgr +else + ${REL_PATH}/paratest3 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Parameter/test004.ksh b/test/sqlgw/Parameter/test004.ksh new file mode 100755 index 00000000..5a43fc26 --- /dev/null +++ b/test/sqlgw/Parameter/test004.ksh @@ -0,0 +1,84 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Parameter/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Parameter +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 DATETIME,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/paratest4 2> $0.valgr +else + ${REL_PATH}/paratest4 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Parameter/test005.ksh b/test/sqlgw/Parameter/test005.ksh new file mode 100755 index 00000000..be9bfded --- /dev/null +++ b/test/sqlgw/Parameter/test005.ksh @@ -0,0 +1,84 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Parameter/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Parameter +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT NULL,f2 SMALLINT NULL,f3 CHAR(30) NULL,f4 REAL NULL,f5 REAL NULL,f6 DATE NULL,f7 TIME NULL,f8 DATETIME NULL,f9 INT NULL,f10 BIGINT NULL);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/paratest5 2> $0.valgr +else + ${REL_PATH}/paratest5 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f create.sql drop.sql +rm -f /tmp/csql.conf +exit 0; diff --git a/test/sqlgw/Parameter/test006.ksh b/test/sqlgw/Parameter/test006.ksh new file mode 100755 index 00000000..03104857 --- /dev/null +++ b/test/sqlgw/Parameter/test006.ksh @@ -0,0 +1,85 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Parameter/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Parameter +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT NULL,f2 SMALLINT NULL,f3 CHAR(30) NULL,f4 REAL NULL,f5 REAL NULL,f6 DATE NULL,f7 TIME NULL,f8 DATETIME NULL,f9 INT NULL,f10 BIGINT NULL);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/paratest6 2> $0.valgr +else + ${REL_PATH}/paratest6 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/Makefile b/test/sqlgw/Select/Makefile new file mode 100644 index 00000000..acf75064 --- /dev/null +++ b/test/sqlgw/Select/Makefile @@ -0,0 +1,57 @@ +OSNAME = $(shell uname -s) +PlatForm=notsupported +ifeq ($(OSNAME), SunOS) + CPlus = CC + CPlusFlags = -O2 -w $(COMPILER_FLAG) + SYSLIBS=-ldl -lnsl -lsocket -lposix4 + PlatForm=supported +endif +ifeq ($(OSNAME), Linux) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif +ifeq ($(OSNAME), FreeBSD) + CPlus = g++ + CPlusFlags = -g -w + SYSLIBS= -rdynamic -lrt -lpthread -lcrypt + PlatForm=supported +endif + + +INCL= -I$(CSQL_INSTALL_ROOT)/install/include -I../../../include +LIBS= -L$(CSQL_INSTALL_ROOT)/lib -lcsqlgw -lcsqlnw -lcsqlodbcadapter -lcsqlsqlnw -lcacheload -lcsql -lcsqlsql -lcsqlsqllog + + +TARGETS = \ + selecttest1 selecttest2 selecttest3 selecttest4 selecttest5 selecttest6 \ + selecttest7 selecttest8 singleconngateway + +ifeq ($(PlatForm), supported) +all: $(TARGETS) +else +all: + echo "CSQL is not supported on $(OSNAME) platform" +endif + +selecttest1: selecttest1.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +selecttest2: selecttest2.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +selecttest3: selecttest3.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +selecttest4: selecttest4.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +selecttest5: selecttest5.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +selecttest6: selecttest6.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +selecttest7: selecttest7.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +selecttest8: selecttest8.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +singleconngateway:singleconngateway.c common.h + $(CPlus) -DGATEWAY $(CPlusFlags) -o $@ $< $(INCL) $(LIBS) $(SYSLIBS) +clean: + rm -f *.o ${TARGETS} diff --git a/test/sqlgw/Select/README b/test/sqlgw/Select/README new file mode 100644 index 00000000..70ed6de1 --- /dev/null +++ b/test/sqlgw/Select/README @@ -0,0 +1,15 @@ +This module runs SQLGwTest cases for with and without parameterized statements. + +All the ksh scripts first create the table in target database. +The table so created is cached into the csql database cache. +The binary executable is run under this script corresponding to the script. +once executable is run the results are compared with the expected file. +The cached table is unloaded. + +VALGRIND can also be run on each of the executable for LEAK Checks by setting +an environmental variable VALGRIND to true and run the script. + +$ export VALGRIND=true +$ testXXX.ksh + +An output file testXXX.ksh.valgr is created for leak reference. diff --git a/test/sqlgw/Select/common.h b/test/sqlgw/Select/common.h new file mode 100644 index 00000000..c859e44d --- /dev/null +++ b/test/sqlgw/Select/common.h @@ -0,0 +1,43 @@ +#include +#include +#include +#include +#include + +AbsSqlConnection *createConnection() +{ +#ifdef NETWORK + AbsSqlConnection *con = SqlFactory::createConnection(CSqlNetwork); + SqlNwConnection *conn = (SqlNwConnection *) con; + conn->setHost("localhost", 5678); +#elif defined NETWORKADAPTER + AbsSqlConnection *con = SqlFactory::createConnection(CSqlNetworkAdapter); + SqlNwConnection *conn = (SqlNwConnection *) con; + conn->setHost("localhost", 5678); +#elif defined NETWORKGATEWAY + AbsSqlConnection *con = SqlFactory::createConnection(CSqlNetworkGateway); + SqlNwConnection *conn = (SqlNwConnection *) con; + conn->setHost("localhost", 5678); +#elif defined GATEWAY + AbsSqlConnection *con = SqlFactory::createConnection(CSqlGateway); +#else + AbsSqlConnection *con = SqlFactory::createConnection(CSqlAdapter); +#endif + return con; +} + +AbsSqlStatement *createStatement() +{ +#ifdef NETWORK + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlNetwork); +#elif defined NETWORKADAPTER + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlNetworkAdapter); +#elif defined NETWORKGATEWAY + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlNetworkGateway); +#elif defined GATEWAY + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlGateway); +#else + AbsSqlStatement *stmt = SqlFactory::createStatement(CSqlAdapter); +#endif + return stmt; +} diff --git a/test/sqlgw/Select/csql.conf b/test/sqlgw/Select/csql.conf new file mode 100644 index 00000000..a2cd9ffa --- /dev/null +++ b/test/sqlgw/Select/csql.conf @@ -0,0 +1,110 @@ +# CSQL System Configuration File + +#####################################Server Section######################## +#Important: For Server section parameters, make sure that the value is same for the +# server process and all the csql client process which connects to it. otherwise, +# behavior is undefined + +# Page size. Each database is logically divided into pages and allocation happens +# in this unit of pages. Increasing this value will reduce frequent allocation of pages. +PAGE_SIZE= 8192 + +#Total number of client process which can connect and work with the +# database concurrently +MAX_PROCS = 100 + +# Maximum size of the system database. +MAX_SYS_DB_SIZE=1048576 + +#Maximum size of the user database file. +MAX_DB_SIZE=10485760 + +#Shared memory key to be used by the system to create and locate system database. +SYS_DB_KEY=4567 + +#Shared memory key to be used by the system to create and locate user database. +USER_DB_KEY=5678 + +#Log level 0->no logging 1->Fine 2->Finer 3->Finest +LOG_LEVEL=0 + +#Give full path for the log file where important system actions are stored. +LOG_FILE=/tmp/csql/log/log.out + +#The virtual memory start address at which the shared memory segment +# will be created and attached. +MAP_ADDRESS=400000000 + +# Whether to enable durability +DURABILITY=false + +# Can be set true only when DURABILITY is true +MMAP=false + +#Give full path for the database file where table and record information will +#be stored for durability +DATABASE_FILE=/tmp/csql/db + +#Important: For Server section parameters, make sure that the value is same for the +# server process and all the csql client process which connects to it. otherwise, +# behavior is undefined +#####################################Client Section######################## + +#Mutex timeout interval seconds +MUTEX_TIMEOUT_SECS=0 +MUTEX_TIMEOUT_USECS=5000 +MUTEX_TIMEOUT_RETRIES=10 + +#Lock timeout interval seconds +LOCK_TIMEOUT_SECS=0 +LOCK_TIMEOUT_USECS=5000 +LOCK_TIMEOUT_RETRIES=10 + +#####################################Cache Section######################## + +#Whether to enable caching of tables from target database +CACHE_TABLE=true + +#Set cache id for multiple bidirectional cache node for single data source +SITE_ID=1 + +#DSN Name to connect to the target database. +#This should be present in ~/odbc.ini file +DSN=myodbc3 + +# Whethere to enable bidirectional updates for cached tables. +ENABLE_BIDIRECTIONAL_CACHE=false + +CACHE_RECEIVER_WAIT_SECS=10 + +#Mode of operation SYNC or ASYNC +CACHE_MODE=SYNC + +##########################SqlNetworkServer Section######################## + +# Whether to enable SqlNetwork server +CSQL_SQL_SERVER=false + +#Set port for Network access +PORT=5678 + +#Whether to enable Replication across the sites +REPLICATION=false + +#No of sites to replicate +REPLICATION_SITES=16 + +#Give full path for the file where all the table information is stored +TABLE_CONFIG_FILE=/tmp/csql/csqltable.conf + +#Give full path of the file where all the DSN information is stored +DS_CONFIG_FILE=/tmp/csql/csqlds.conf + +#Give full path for the file where all the peer site information is stored +NETWORK_CONFIG_FILE=/tmp/csql/csqlnw.conf + +# MSGKEY for creating msg queue for MsgQueue Server +MSG_KEY=2530 + +ID_SHM_KEY=1950 +#####################################End Section######################## diff --git a/test/sqlgw/Select/exp.test009.ksh b/test/sqlgw/Select/exp.test009.ksh new file mode 100644 index 00000000..167a21e3 --- /dev/null +++ b/test/sqlgw/Select/exp.test009.ksh @@ -0,0 +1,77 @@ +Inserting records into table T1 +5 rows inserted into table T1 +Inserting records into table T2 +5 rows inserted into table T2 +Inserting records into table T3 +5 rows inserted into table T3 ++---------------------------------------+ +| Connected! | +| | +| sql-statement | +| help [tablename] | +| quit | +| | ++---------------------------------------+ +[?1034hSQL> SELECT * FROM T1; ++-----------+-----------------------------------+ +| f1 | f2 | ++-----------+-----------------------------------+ +| 0 | lakshya | +| 1 | lakshya | +| 2 | lakshya | +| 3 | lakshya | +| 4 | lakshya | ++-----------+-----------------------------------+ +SQLRowCount returns 5 +5 rows fetched +SQL> SELECT * FROM T2; ++-----------+-----------------------------------+ +| f1 | f2 | ++-----------+-----------------------------------+ +| 5 | lakshya | +| 6 | lakshya | +| 7 | lakshya | +| 8 | lakshya | +| 9 | lakshya | ++-----------+-----------------------------------+ +SQLRowCount returns 5 +5 rows fetched +SQL> SELECT * FROM T3; ++-----------+-----------------------------------+ +| f1 | f2 | ++-----------+-----------------------------------+ +| 10 | lakshya | +| 11 | lakshya | +| 12 | lakshya | +| 13 | lakshya | +| 14 | lakshya | ++-----------+-----------------------------------+ +SQLRowCount returns 5 +5 rows fetched +SQL> --------------------------------------------------------- + T1.f1 T1.f2 +--------------------------------------------------------- + 0 lakshya + 1 lakshya + 2 lakshya + 3 lakshya + 4 lakshya + +--------------------------------------------------------- + T2.f1 T2.f2 +--------------------------------------------------------- + 5 lakshya + 6 lakshya + 7 lakshya + 8 lakshya + 9 lakshya + +--------------------------------------------------------- + T3.f1 T3.f2 +--------------------------------------------------------- + 10 lakshya + 11 lakshya + 12 lakshya + 13 lakshya + 14 lakshya + diff --git a/test/sqlgw/Select/exp.test009.ksh.psql b/test/sqlgw/Select/exp.test009.ksh.psql new file mode 100644 index 00000000..0263dc02 --- /dev/null +++ b/test/sqlgw/Select/exp.test009.ksh.psql @@ -0,0 +1,80 @@ +Inserting records into table T1 +5 rows inserted into table T1 +Inserting records into table T2 +5 rows inserted into table T2 +Inserting records into table T3 +5 rows inserted into table T3 ++---------------------------------------+ +| Connected! | +| | +| sql-statement | +| help [tablename] | +| quit | +| | ++---------------------------------------+ +[?1034hSQL> SELECT * FROM T1; ++------------+-----------------------------------+ +| f1 | f2 | ++------------+-----------------------------------+ +| | | +| 0 | lakshya | +| 1 | lakshya | +| 2 | lakshya | +| 3 | lakshya | +| 4 | lakshya | ++------------+-----------------------------------+ +SQLRowCount returns 6 +6 rows fetched +SQL> SELECT * FROM T2; ++------------+-----------------------------------+ +| f1 | f2 | ++------------+-----------------------------------+ +| | | +| 5 | lakshya | +| 6 | lakshya | +| 7 | lakshya | +| 8 | lakshya | +| 9 | lakshya | ++------------+-----------------------------------+ +SQLRowCount returns 6 +6 rows fetched +SQL> SELECT * FROM T3; ++------------+-----------------------------------+ +| f1 | f2 | ++------------+-----------------------------------+ +| | | +| 10 | lakshya | +| 11 | lakshya | +| 12 | lakshya | +| 13 | lakshya | +| 14 | lakshya | ++------------+-----------------------------------+ +SQLRowCount returns 6 +6 rows fetched +SQL> --------------------------------------------------------- + T1.f1 T1.f2 +--------------------------------------------------------- + 0 lakshya + 1 lakshya + 2 lakshya + 3 lakshya + 4 lakshya + +--------------------------------------------------------- + T2.f1 T2.f2 +--------------------------------------------------------- + 5 lakshya + 6 lakshya + 7 lakshya + 8 lakshya + 9 lakshya + +--------------------------------------------------------- + T3.f1 T3.f2 +--------------------------------------------------------- + 10 lakshya + 11 lakshya + 12 lakshya + 13 lakshya + 14 lakshya + diff --git a/test/sqlgw/Select/selecttest1.c b/test/sqlgw/Select/selecttest1.c new file mode 100644 index 00000000..6954e8cd --- /dev/null +++ b/test/sqlgw/Select/selecttest1.c @@ -0,0 +1,133 @@ +/* create table T1 with 10 fields, + * insert 10 rows into the table , + * noofprojFields shoul dreturn 10. + * call fetch and count the record. +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows=0; + // insert records + + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + } else { + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + } + + int f1var = 99; + short int f2var = 1; + char f3var[32] = "lakshya"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2008,1,21); + + Time f7var; + f7var.set(12,29,30); + + TimeStamp f8var; + f8var.setDate(2008,1,21); + f8var.setTime(12,29,30); + + int f9var = 20; + long long f10var = 12000; + + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 4; } + + int count=0; + + for(int i=0;i<2;i++) { + f1var = f1var+i; + for(int j=0;j<5;j++) { + rv = con->beginTrans(); + if(rv!=OK)break; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setFloatParam(5,f5var); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setTimeParam(7,f7var); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + } + printf("%d Rows Inserted\n",count); + stmt->free(); + +//******************************************* + + strcpy(statement,"SELECT * FROM t1 WHERE f1=100;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT * FROM t1 WHERE f1=100"); + rv = stmt->prepare(statement); + int nop; + nop = stmt->noOfProjFields(); + printf("noOfProjFields returns=%d\n",nop); + if(rv !=OK) { delete stmt; delete con; return 5; } + + stmt->bindField(1,&f1var); + stmt->bindField(2,&f2var); + stmt->bindField(3,f3var); + stmt->bindField(4,&f4var); + stmt->bindField(5,&f5var); + stmt->bindField(6,&f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->bindField(7,&f8var); + stmt->bindField(8,&f9var); + stmt->bindField(9,&f10var); + }else{ + stmt->bindField(7,&f7var); + stmt->bindField(8,&f8var); + stmt->bindField(9,&f9var); + stmt->bindField(10,&f10var); + } + count = 0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + printf("Fetching starts on table 'T1' :\n"); + while(stmt->fetch()!=NULL) { + if(strcmp(getenv("DSN"),"oracle")==0) + printf("f1=%d | f2=%hd | f3=%s | f4=%f | f5=%f | DATE=%d-%d-%d | TIMESTAMP=%d-%d-%d %d:%d:%d | f9=%d | f10=%lld\n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + else + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIME=%d:%d:%d | TIMESTAMP=%d-%d-%d %d:%d:%d | F9=%d | F10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f7var.hours(),f7var.minutes(),f7var.seconds(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + count++; + } + stmt->close(); + rv = con->commit(); + if(rv!=OK) { delete stmt; delete con; return 7; } + + printf("%d Rows fetched\n",count); + + stmt->free(); + delete stmt; + delete con; + return 0; +} diff --git a/test/sqlgw/Select/selecttest2.c b/test/sqlgw/Select/selecttest2.c new file mode 100644 index 00000000..f001dfb7 --- /dev/null +++ b/test/sqlgw/Select/selecttest2.c @@ -0,0 +1,143 @@ +/* create table T1 with 10 fields, + * insert 10 rows into the table , + * noofprojFields should return 5. + * getProjFldInfo() for all fields. + * select with 5 parameters withIwhere clause.(WHERE F1=100) +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + + int rows=0; + + // insert records + + if(strcmp(getenv("DSN"),"oracle")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?);"); + } + else if(strcmp(getenv("DSN"),"db2")==0){ + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?)"); + } else { + strcpy(statement,"INSERT INTO t1 VALUES(?,?,?,?,?,?,?,?,?,?);"); + } + + int f1var = 99; + short int f2var = 1; + char f3var[32] = "lakshya"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2008,1,21); + + Time f7var; + f7var.set(12,29,30); + + TimeStamp f8var; + f8var.setDate(2008,1,21); + f8var.setTime(12,29,30); + + int f9var = 20; + long long f10var = 12000; + + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 4; } + + int count=0; + + for(int i=0;i<2;i++) { + f1var = f1var+i; + for(int j=0;j<5;j++) { + rv = con->beginTrans(); + if(rv!=OK)break; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + stmt->setStringParam(3,f3var); + stmt->setFloatParam(4,f4var); + stmt->setFloatParam(5,f5var); + stmt->setDateParam(6,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + }else{ + stmt->setTimeParam(7,f7var); + stmt->setTimeStampParam(8,f8var); + stmt->setIntParam(9,f9var); + stmt->setLongLongParam(10,f10var); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + + } + printf("%d Rows Inserted\n",count); + stmt->free(); + +//******************************************* + + strcpy(statement,"SELECT f8,f10,f2,f6,f3 FROM t1 WHERE f1=100;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT f8,f10,f2,f6,f3 FROM t1 WHERE f1=100"); + rv = stmt->prepare(statement); + + int nop; + nop = stmt->noOfProjFields(); + if(nop!=5)return 1; + printf("Total number of projection fields in the select statement=%d\n",nop); + + // getParamFldInfo() + FieldInfo *field = new FieldInfo(); + + char fldName[20]; + DataType type; + size_t length; + int offset; + char defaultValueBuf[10]; + bool isNull; + bool isDefault; + + delete field; + + if(rv !=OK) { delete stmt; delete con; return 5; } + + stmt->bindField(1,&f8var); + stmt->bindField(2,&f10var); + stmt->bindField(3,&f2var); + stmt->bindField(4,&f6var); + stmt->bindField(5,f3var); + count = 0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + while(stmt->fetch()!=NULL) { + if(strcmp(getenv("DSN"),"oracle")==0) + printf("f1=%d | f2=%hd | f3=%s | f4=%f | f5=%f | DATE=%d-%d-%d | TIMESTAMP=%d-%d-%d %d:%d:%d | f9=%d | f10=%lld\n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + else + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIME=%d:%d:%d | TIMESTAMP=%d-%d-%d %d:%d:%d | F9=%d | F10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f7var.hours(),f7var.minutes(),f7var.seconds(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + + count++; + } + + stmt->close(); + rv = con->commit(); + if(rv!=OK) { delete stmt; delete con; return 6; } + + printf("Total row fetched=%d\n",count); + + stmt->free(); delete stmt; delete con; return 0; +} + + + diff --git a/test/sqlgw/Select/selecttest3.c b/test/sqlgw/Select/selecttest3.c new file mode 100644 index 00000000..a838fbc6 --- /dev/null +++ b/test/sqlgw/Select/selecttest3.c @@ -0,0 +1,89 @@ +/* create table t1 with two fields, + * insert 10 rows into the table , + * select from nonexisting table. +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + + int rows=0; + // insert records + + strcpy(statement,"INSERT INTO t1 VALUES(?,?);"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"INSERT INTO t1 VALUES(?,?)"); + + int f1var = 1; + char f2var[20] = "lakshya"; + + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 3; } + + int count=0; + + for(int i=0;i<2;i++) { + for(int j=0;j<5;j++) { + f1var = j; + rv = con->beginTrans(); + if(rv!=OK)break; + stmt->setIntParam(1,f1var); + stmt->setStringParam(2,f2var); + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("%d rows inserted\n",count); + } + stmt->free(); + +//******************************************* + + strcpy(statement,"SELECT * FROM t11;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT * FROM t11"); + rv = stmt->prepare(statement); + + if(rv !=OK) { + printf("test script passed\n"); + stmt->free(); + delete stmt; + delete con; + return 0; + } else if(rv==OK) { + if(strcmp(getenv("DSN"),"oracle")==0 || strcmp(getenv("DSN"),"psql")==0 || strcmp(getenv("DSN"),"sybase")==0){ + printf("Test script Passed\n"); + stmt->free(); delete stmt; delete con; return 0; + } else { + printf("Test script failed\n"); + stmt->free(); delete stmt; delete con; return 5; + } + } else { + stmt->bindField(1,&f1var); + stmt->bindField(2,f2var); + count = 0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + while(stmt->fetch()!=NULL) + { count++; } + stmt->close(); + rv = con->commit(); + if(rv!=OK) { delete stmt; delete con; return 7; } + printf("Total row fetched=%d\n",count); + } + stmt->free(); delete stmt; delete con; return 0; + } + + + diff --git a/test/sqlgw/Select/selecttest4.c b/test/sqlgw/Select/selecttest4.c new file mode 100644 index 00000000..fd1b8155 --- /dev/null +++ b/test/sqlgw/Select/selecttest4.c @@ -0,0 +1,66 @@ +/* create table t1 with two fields, + * insert 10 rows into the table , + * select with nonexisting fields.It Should be failed in Mysql, Passed in postgres and oracle +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows = 0; + // insert records + + strcpy(statement,"INSERT INTO t1 VALUES(?,?);"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"INSERT INTO t1 VALUES(?,?)"); + + int f1var = 1; + int f2var= 110; + + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 3; } + + int count=0; + + for( int i = 0; i < 2; i++ ) { + for( int j = 0; j < 5; j++ ) { + f1var = j; + rv = con->beginTrans(); + if(rv != OK) break; + stmt->setIntParam(1,f1var); + stmt->setIntParam(2,f2var); + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("%d rows inserted\n",count); + } + stmt->free(); + +//******************************************* + strcpy(statement,"SELECT F3 ,f2 FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT F3 ,f2 FROM t1"); + rv = stmt->prepare(statement); + if(rv !=OK) { + printf("Test script passed\n"); + delete stmt; delete con; return 0; + } else { + if(strcmp(getenv("DSN"),"oracle")==0 || strcmp(getenv("DSN"),"psql")==0 || strcmp(getenv("DSN"),"sybase")==0) + { + printf("Test script Passed\n"); + delete stmt; delete con; return 0; + } else { + printf("Test script failed\n"); + delete stmt; delete con; return 4; } + } +} diff --git a/test/sqlgw/Select/selecttest5.c b/test/sqlgw/Select/selecttest5.c new file mode 100644 index 00000000..9a46bdff --- /dev/null +++ b/test/sqlgw/Select/selecttest5.c @@ -0,0 +1,30 @@ +/* call execute without calling prepare. it should fail. +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + strcpy(statement,"INSERT INTO t1 VALUES (1, 'jitendra');"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"INSERT INTO t1 VALUES (1, 'jitendra')"); + int rows=0; + rv = stmt->execute(rows); + if(rv!=OK) { + delete stmt; + delete con; + printf("Test script passed\n"); + return 0; + } + stmt->free(); + printf("Test script failed\n"); + delete stmt; + delete con; + return 1; +} diff --git a/test/sqlgw/Select/selecttest6.c b/test/sqlgw/Select/selecttest6.c new file mode 100644 index 00000000..1fcb47b2 --- /dev/null +++ b/test/sqlgw/Select/selecttest6.c @@ -0,0 +1,76 @@ +/* create table t1 with two fields, + * insert 10 rows into the table , + * fetch without prepare. +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + + int rows=0; + // insert records + + strcpy(statement,"INSERT INTO t1 VALUES(?,?);"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"INSERT INTO t1 VALUES(?,?)"); + + int f1var = 1; + char f2var[20] = "lakshya"; + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 3; } + + int count=0; + + for(int i=0;i<2;i++) { + for(int j=0;j<5;j++) { + f1var = j; + rv = con->beginTrans(); + if(rv!=OK)break; + stmt->setIntParam(1,f1var); + stmt->setStringParam(2,f2var); + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("%d rows inserted\n",count); + } + stmt->free(); + +//******************************************* + + strcpy(statement,"SELECT * FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT * FROM t1"); + stmt->bindField(1,&f1var); + stmt->bindField(2,f2var); + + void *ret; + count = 0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + + while(1) { + ret = ((char*)stmt->fetch(rv)); + if(ret ==NULL && rv == ErrNotPrepared) { + printf("fetch failed without prepare\n"); + delete stmt; + delete con; + return 0; + } + printf("Test script failed\n"); + } + delete stmt; + delete con; + return 8; +} diff --git a/test/sqlgw/Select/selecttest7.c b/test/sqlgw/Select/selecttest7.c new file mode 100644 index 00000000..676cdc6b --- /dev/null +++ b/test/sqlgw/Select/selecttest7.c @@ -0,0 +1,87 @@ +/* create table t1 with two fields, + * insert 10 rows into the table , + * call fetch without call execute,it returns NULL. +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + + int rows=0; + + // insert records + + strcpy(statement,"INSERT INTO t1 VALUES(?,?);"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"INSERT INTO t1 VALUES(?,?)"); + + int f1var = 1; + char f2var[20] = "lakshya"; + + rv = stmt->prepare(statement); + if(rv!=OK) { + delete stmt; + delete con; + return 3; + } + + int count=0; + + for(int i=0;i<2;i++) { + for(int j=0;j<5;j++) { + f1var = j; + rv = con->beginTrans(); + if(rv!=OK)break; + stmt->setIntParam(1,f1var); + stmt->setStringParam(2,f2var); + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + printf("%d rows inserted\n",count); + } + stmt->free(); + +//******************************************* + + strcpy(statement,"SELECT * FROM t1;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT * FROM t1"); + rv = stmt->prepare(statement); + if(rv !=OK) { delete stmt; delete con; return 4; } + stmt->bindField(1,&f1var); + stmt->bindField(2,f2var); + + void *ret; + count = 0; + rv = con->beginTrans(); + if(rv!=OK)return 5; + //stmt->execute(rows); + while(1) { + ret = ((char*)stmt->fetch(rv)); + if(ret==NULL && rv == ErrNotOpen) { + printf("Fetch failed without execute.\n"); + printf("Test script passed.\n"); + delete stmt; + delete con; + return 0; + } + printf("Test script failed\n"); + } + stmt->free(); + con->commit(); + delete stmt; + delete con; + return 7; +} + diff --git a/test/sqlgw/Select/selecttest8.c b/test/sqlgw/Select/selecttest8.c new file mode 100644 index 00000000..abcac43a --- /dev/null +++ b/test/sqlgw/Select/selecttest8.c @@ -0,0 +1,127 @@ +/* create table t1 with 10 fields,( f2 NOT NULL , f3 CHAR(20) DEFAULT 'LAKSHYA') + * insert 10 rows for 9 Fields except f3 Field into the table + * noofprojFields should return 5. + * getProjFldInfo() for all fields. + * select with 5 parameters withIwhere clause.(WHERE f1=100) +*/ + +#include "common.h" +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + + AbsSqlStatement *stmt = createStatement(); + stmt->setConnection(con); + char statement[200]; + int rows=0; + + // insert records + if(strcmp(getenv("DSN"),"oracle")==0) + strcpy(statement,"INSERT INTO t1(f1,f2,f4,f5,f6,f8,f9,f10)VALUES(?,?,?,?,?,?,?,?);"); + else if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"INSERT INTO t1(f1,f2,f4,f5,f6,f7,f8,f9,f10)VALUES(?,?,?,?,?,?,?,?,?)"); + else + strcpy(statement,"INSERT INTO t1(f1,f2,f4,f5,f6,f7,f8,f9,f10)VALUES(?,?,?,?,?,?,?,?,?);"); + + int f1var = 99; + short int f2var = 1; + // char f3var[20] = "prabakaran"; + float f4var = 5.5; + float f5var = 10.50; + Date f6var; + f6var.set(2008,1,21); + + Time f7var; + f7var.set(12,29,30); + + TimeStamp f8var; + f8var.setDate(2008,1,21); + f8var.setTime(12,29,30); + + int f9var = 20; + long long f10var = 12000; + + rv = stmt->prepare(statement); + if(rv!=OK) { delete stmt; delete con; return 4; } + + int count=0; + + for(int i=0;i<2;i++) { + f1var = f1var+i; + for(int j=0;j<5;j++) { + rv = con->beginTrans(); + if(rv!=OK)break; + stmt->setIntParam(1,f1var); + stmt->setShortParam(2,f2var); + //stmt->setStringParam(3,f3var); + stmt->setFloatParam(3,f4var); + stmt->setFloatParam(4,f5var); + stmt->setDateParam(5,f6var); + if(strcmp(getenv("DSN"),"oracle")==0){ + stmt->setTimeStampParam(6,f8var); + stmt->setIntParam(7,f9var); + stmt->setLongLongParam(8,f10var); + } else { + stmt->setTimeParam(6,f7var); + stmt->setTimeStampParam(7,f8var); + stmt->setIntParam(8,f9var); + stmt->setLongLongParam(9,f10var); + } + rv = stmt->execute(rows); + if(rv!=OK)break; + rv = con->commit(); + if(rv!=OK)break; + count++; + } + } + printf("%d Rows Inserted\n",count); + stmt->free(); + +//******************************************* + + strcpy(statement,"SELECT f8,f10,f2,f6,f3 FROM t1 WHERE f1=100;"); + if(strcmp(getenv("DSN"),"db2")==0) + strcpy(statement,"SELECT f8,f10,f2,f6,f3 FROM t1 WHERE f1=100"); + rv = stmt->prepare(statement); + if(rv !=OK) { delete stmt; delete con; return 5; } + + int nop; + nop = stmt->noOfProjFields(); + if(nop!=5)return 1; + printf("Total number of projection fields in the select statement=%d\n",nop); + char fldName[20]; + DataType type; + size_t length; + int offset; + char defaultValueBuf[10]; + bool isNull; + bool isDefault; + char f3var[32]="jitu"; + + stmt->bindField(1,&f8var); + stmt->bindField(2,&f10var); + stmt->bindField(3,&f2var); + stmt->bindField(4,&f6var); + stmt->bindField(5,f3var); + count = 0; + rv = con->beginTrans(); + if(rv!=OK)return 6; + stmt->execute(rows); + while(stmt->fetch()!=NULL) { + printf("F1=%d | F2=%hd | F3=%s | F4=%f | F5=%f | DATE=%d-%d-%d | TIME=%d:%d:%d | TIMESTAMP=%d-%d-%d %d:%d:%d | f9=%d | f10=%lld \n",f1var,f2var,f3var,f4var,f5var,f6var.year(),f6var.month(),f6var.dayOfMonth(),f7var.hours(),f7var.minutes(),f7var.seconds(),f8var.year(),f8var.month(),f8var.dayOfMonth(),f8var.hours(),f8var.minutes(),f8var.seconds(),f9var,f10var); + count++; + } + + stmt->close(); + rv = con->commit(); + if(rv!=OK) { delete stmt; delete con; return 6; } + + printf("Total row fetched=%d\n",count); + stmt->free(); + delete stmt; + delete con; + return 0; +} diff --git a/test/sqlgw/Select/singleconngateway.c b/test/sqlgw/Select/singleconngateway.c new file mode 100644 index 00000000..afa444b9 --- /dev/null +++ b/test/sqlgw/Select/singleconngateway.c @@ -0,0 +1,116 @@ +/*One connection working with multiple statements + *create table T1 with two fields, + *One connection working with multiple statements simultaneously for csql, + *Create conn + *create 3 stmts for inserting into 5 tables and set the same connection + *insert into all 3 tables and commit the transaction + *free all stmts + *select the records from 3 tables in same connection + *free all stmt; + *Author : Nihar Paital + */ + +#include"common.h" + +int main() +{ + DbRetVal rv = OK; + AbsSqlConnection *con = createConnection(); + rv = con->connect("root","manager"); + if(rv!=OK)return 1; + AbsSqlStatement *stmt1 = createStatement(); + AbsSqlStatement *stmt2 = createStatement(); + AbsSqlStatement *stmt3 = createStatement(); + char statement[200]; + + stmt1->setConnection(con); + stmt2->setConnection(con); + stmt3->setConnection(con); + int rows=0; + void *f1varT1 = NULL; + void *f1varT2 = NULL; + void *f1varT3 = NULL; +// insert records into T1 + if(strcmp(getenv("DSN"),"oracle")==0) { + f1varT1 = malloc(sizeof(long long)); + f1varT2 = malloc(sizeof(long long)); + f1varT3 = malloc(sizeof(long long)); + } else { + f1varT1 = malloc(sizeof(int)); + f1varT2 = malloc(sizeof(int)); + f1varT3 = malloc(sizeof(int)); + } + char f2varT1[36] = "lakshya"; + printf("Inserting records into table T1\n"); + strcpy(statement,"INSERT INTO T1 VALUES(?,?);"); + rv = stmt1->prepare(statement); + if(rv!=OK) { delete stmt1; delete con; return 3; } + int count=0; + rv = con->beginTrans(); + for(int j=0;j<5;j++) { + if(strcmp(getenv("DSN"),"oracle")==0) { + *(long long *) f1varT1 = j; + stmt1->setLongLongParam(1,*(long long *)f1varT1); + } else { + *(int *) f1varT1 = j; + stmt1->setIntParam(1,*(int *) f1varT1); + } + stmt1->setStringParam(2,f2varT1); + rv = stmt1->execute(rows); + if(rv!=OK)break; + count++; + } + printf("%d rows inserted into table T1\n",count); + +// insert records into T2 + char f2varT2[36] = "lakshya"; + printf("Inserting records into table T2\n"); + strcpy(statement,"INSERT INTO T2 VALUES(?,?);"); + rv = stmt2->prepare(statement); + if(rv!=OK) { delete stmt2; delete con; return 3; } + count=0; + for(int j=5;j<10;j++) { + if(strcmp(getenv("DSN"),"oracle")==0) { + *(long long *) f1varT2 = j; + stmt2->setLongLongParam(1,*(long long *)f1varT2); + } else { + *(int *) f1varT2 = j; + stmt2->setIntParam(1,*(int *) f1varT2); + } + stmt2->setStringParam(2,f2varT2); + rv = stmt2->execute(rows); + if(rv!=OK)break; + count++; + } + printf("%d rows inserted into table T2\n",count); + +// insert records into T3 + char f2varT3[36] = "lakshya"; + printf("Inserting records into table T3\n"); + strcpy(statement,"INSERT INTO T3 VALUES(?,?);"); + rv = stmt3->prepare(statement); + if(rv!=OK) { delete stmt3; delete con; return 3; } + count=0; + for(int j=10;j<15;j++) { + if(strcmp(getenv("DSN"),"oracle")==0) { + *(long long *) f1varT3 = j; + stmt3->setLongLongParam(1,*(long long *)f1varT3); + } else { + *(int *) f1varT3 = j; + stmt3->setIntParam(1,*(int *) f1varT3); + } + stmt3->setStringParam(2,f2varT3); + rv = stmt3->execute(rows); + if(rv!=OK)break; + count++; + } + printf("%d rows inserted into table T3\n",count); + rv = con->commit(); + + free(f1varT1); free(f1varT2); free(f1varT3); + stmt1->free(); delete stmt1; + stmt2->free(); delete stmt2; + stmt3->free(); delete stmt3; + delete con; + return 0; +} diff --git a/test/sqlgw/Select/test001.ksh b/test/sqlgw/Select/test001.ksh new file mode 100755 index 00000000..5d780971 --- /dev/null +++ b/test/sqlgw/Select/test001.ksh @@ -0,0 +1,84 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 DATETIME,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest1 2> $0.valgr +else + ${REL_PATH}/selecttest1 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test002.ksh b/test/sqlgw/Select/test002.ksh new file mode 100755 index 00000000..a803699c --- /dev/null +++ b/test/sqlgw/Select/test002.ksh @@ -0,0 +1,84 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 DATETIME,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest2 2> $0.valgr +else + ${REL_PATH}/selecttest2 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test003.ksh b/test/sqlgw/Select/test003.ksh new file mode 100755 index 00000000..fa1dc17b --- /dev/null +++ b/test/sqlgw/Select/test003.ksh @@ -0,0 +1,81 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20))" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest3 2> $0.valgr +else + ${REL_PATH}/selecttest3 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test004.ksh b/test/sqlgw/Select/test004.ksh new file mode 100755 index 00000000..a609606f --- /dev/null +++ b/test/sqlgw/Select/test004.ksh @@ -0,0 +1,81 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20))" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest4 2> $0.valgr +else + ${REL_PATH}/selecttest4 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test005.ksh b/test/sqlgw/Select/test005.ksh new file mode 100755 index 00000000..cb4c7161 --- /dev/null +++ b/test/sqlgw/Select/test005.ksh @@ -0,0 +1,81 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20))" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest5 2> $0.valgr +else + ${REL_PATH}/selecttest5 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test006.ksh b/test/sqlgw/Select/test006.ksh new file mode 100755 index 00000000..0b6ccfb7 --- /dev/null +++ b/test/sqlgw/Select/test006.ksh @@ -0,0 +1,81 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20))" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest6 2> $0.valgr +else + ${REL_PATH}/selecttest6 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test007.ksh b/test/sqlgw/Select/test007.ksh new file mode 100755 index 00000000..e4468abc --- /dev/null +++ b/test/sqlgw/Select/test007.ksh @@ -0,0 +1,81 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20))" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 CHAR(20));" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ $VALGRIND = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest7 2> $0.valgr +else + ${REL_PATH}/selecttest7 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test008.ksh b/test/sqlgw/Select/test008.ksh new file mode 100755 index 00000000..3e72fd6d --- /dev/null +++ b/test/sqlgw/Select/test008.ksh @@ -0,0 +1,84 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +if [ $DSN = "psql" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT4,f5 FLOAT4,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "sybase" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30) NULL,f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 DATETIME,f9 INT,f10 BIGINT);" > create.sql +elif [ $DSN = "oracle" ] +then + echo "CREATE TABLE t1(f1 number(9),f2 number(4),f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f8 TIMESTAMP,f9 number(9),f10 number(18));" > create.sql +elif [ $DSN = "db2" ] +then + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30), f4 REAL,f5 REAL,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT)" > create.sql +else + echo "CREATE TABLE t1(f1 INT,f2 SMALLINT,f3 CHAR(30),f4 FLOAT,f5 FLOAT,f6 DATE,f7 TIME,f8 TIMESTAMP,f9 INT,f10 BIGINT);" > create.sql +fi + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table t1;" > drop.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 1; +fi + +if [ "$VALGRIND" = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/selecttest8 2> $0.valgr +else + ${REL_PATH}/selecttest8 + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql + exit 2; + fi +fi + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t t1 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql +exit 0; diff --git a/test/sqlgw/Select/test009.ksh b/test/sqlgw/Select/test009.ksh new file mode 100755 index 00000000..ed8565a1 --- /dev/null +++ b/test/sqlgw/Select/test009.ksh @@ -0,0 +1,105 @@ +#!/bin/ksh + +CSQL_CONF=${PWD}/sqlgw/Select/csql.conf +REL_PATH=. +if [ -s "$CSQL_CONF" ] +then + REL_PATH=${PWD}/sqlgw/Select +fi +rm -f /tmp/csql.conf +cp $REL_PATH/csql.conf /tmp/csql.conf + +export CSQL_CONFIG_FILE=/tmp/csql.conf +echo DSN=$DSN >>$CSQL_CONFIG_FILE +DS="$DSN $DBUSER $PASSWORD" + +rm -f /tmp/csql/csqlds.conf +touch /tmp/csql/csqlds.conf +rm -f /tmp/csql/csqltable.conf +touch /tmp/csql/csqltable.conf + +$CSQL_INSTALL_ROOT/bin/csqlds -U $DBUSER -P $PASSWORD -D $DSN -N $TDB -a +if [ $? -ne 0 ] +then + exit 1; +fi + +echo "CREATE TABLE T1(f1 INT,f2 CHAR(34));" > create.sql +echo "CREATE TABLE T2(f1 INT,f2 CHAR(34));" >> create.sql +echo "CREATE TABLE T3(f1 INT,f2 CHAR(34));" >> create.sql + +isql $DS < create.sql >/dev/null 2>&1 + +$CSQL_INSTALL_ROOT/bin/csqlserver >/dev/null 2>&1 & +pid=$! +sleep 5 + +echo "drop table T1;" > drop.sql +echo "drop table T2;" >> drop.sql +echo "drop table T3;" >> drop.sql + +echo "SELECT * FROM T1;" >sel.sql +echo "SELECT * FROM T2;" >>sel.sql +echo "SELECT * FROM T3;" >>sel.sql + +$CSQL_INSTALL_ROOT/bin/cachetable -t T1 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql sel.sql + exit 2; +fi + +$CSQL_INSTALL_ROOT/bin/cachetable -t T2 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql sel.sql + exit 3; +fi + +$CSQL_INSTALL_ROOT/bin/cachetable -t T3 +if [ $? -ne 0 ] +then + isql $DS < drop.sql >/dev/null 2>&1 + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql sel.sql + exit 4; +fi + +if [ "$VALGRIND" = "true" ] +then + valgrind --tool=memcheck --leak-check=full ${REL_PATH}/singleconngateway 2> $0.valgr +else + ${REL_PATH}/singleconngateway + if [ $? -ne 0 ] + then + isql $DS < drop.sql >/dev/null 2>&1 + $CSQL_INSTALL_ROOT/bin/cachetable -t T1 -u + $CSQL_INSTALL_ROOT/bin/cachetable -t T2 -u + $CSQL_INSTALL_ROOT/bin/cachetable -t T3 -u + $CSQL_INSTALL_ROOT/bin/csql -s drop.sql + kill -9 $pid + ipcrm -M 4567 -M 5678 -M 1950 + rm -f create.sql drop.sql sel.sql + exit 5; + fi +fi + +isql $DS < sel.sql +$CSQL_INSTALL_ROOT/bin/csql -s sel.sql + +isql $DS < drop.sql >/dev/null 2>&1 +$CSQL_INSTALL_ROOT/bin/cachetable -t T1 -u +$CSQL_INSTALL_ROOT/bin/cachetable -t T2 -u +$CSQL_INSTALL_ROOT/bin/cachetable -t T3 -u +kill -9 $pid +ipcrm -M 4567 -M 5678 -M 1950 +rm -f /tmp/csql.conf +rm -f create.sql drop.sql sel.sql +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest1.java b/test/sqlnetwork/Jdbcnetwork/ConnTest1.java new file mode 100755 index 00000000..c6300a63 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest1.java @@ -0,0 +1,20 @@ +//Connect with connect string "jdbc:csql://localhost:5678/csql" and give correct "user" and "password" in properties object. It should pass. +import java.sql.*; +public class ConnTest1 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + if ( con == null ) System.exit(1); + con.close(); + System.exit(0); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.getStackTrace(); + System.exit(1); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest10.java b/test/sqlnetwork/Jdbcnetwork/ConnTest10.java new file mode 100644 index 00000000..f13d3ee3 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest10.java @@ -0,0 +1,19 @@ +//Connect with "jdbc:csql://5678:localhost/csql" and give correct "user" and "password" in properties object. It should fail + +import java.sql.*; +public class ConnTest10 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://5678:localhost/csql", "root", "manager"); + if (con != null) System.exit(1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest11.java b/test/sqlnetwork/Jdbcnetwork/ConnTest11.java new file mode 100644 index 00000000..30a2266e --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest11.java @@ -0,0 +1,19 @@ +// Connect with "jdbc:csql://localhost:5678" and give correct "user" and "password" in properties object. It should pass as for csql default database is csql +import java.sql.*; +public class ConnTest11 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678", "root", "manager"); + if (con == null) System.exit(1); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit (1); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest12.java b/test/sqlnetwork/Jdbcnetwork/ConnTest12.java new file mode 100644 index 00000000..8d9a88cb --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest12.java @@ -0,0 +1,18 @@ +//Connect with "jdbc:csql://local/host:5678/csql" and give correct "user" and "password" in properties object. It should fail +import java.sql.*; +public class ConnTest12 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://local/host:5678/csql", "root", "manager"); + if (con != null) System.exit (1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest13.java b/test/sqlnetwork/Jdbcnetwork/ConnTest13.java new file mode 100644 index 00000000..dcda009e --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest13.java @@ -0,0 +1,18 @@ +//Connect with "jdbc:csql:localhost:5678" and give correct "user" and "password" in properties object. It should fail +import java.sql.*; +public class ConnTest13 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql:localhost:5678", "root", "manager"); + if (con != null) System.exit(1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest14.java b/test/sqlnetwork/Jdbcnetwork/ConnTest14.java new file mode 100644 index 00000000..f88486a9 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest14.java @@ -0,0 +1,18 @@ +//Connect with "jdbc:csql://localhost:5678csql" and give correct "user" and "password" in properties object. It should fail +import java.sql.*; +public class ConnTest14 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678csql", "root", "manager"); + if (con != null) System.exit (1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit (0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest15.java b/test/sqlnetwork/Jdbcnetwork/ConnTest15.java new file mode 100644 index 00000000..f6c59d38 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest15.java @@ -0,0 +1,18 @@ +//Connect with "jdbc:csql//localhost:5678/csql" and give correct "user" and "password" in properties object. It should fail +import java.sql.*; +public class ConnTest15 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql//localhost:5678/csql","root","manager"); + if(con!=null) {con.close(); System.exit(1);} + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest16.java b/test/sqlnetwork/Jdbcnetwork/ConnTest16.java new file mode 100644 index 00000000..5955227e --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest16.java @@ -0,0 +1,25 @@ +//Try to open , close , open . it should pass +import java.sql.*; +public class ConnTest16 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + if ( con == null ) + System.exit(1); + con.close(); + con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql","root","manager"); + if ( con == null ) + System.exit(1); + con.close(); + System.exit(0); + }catch(Exception e) { + System.out.println(e.getMessage()); + e.getStackTrace(); + System.exit(1); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest17.java b/test/sqlnetwork/Jdbcnetwork/ConnTest17.java new file mode 100644 index 00000000..395a7846 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest17.java @@ -0,0 +1,24 @@ +//Close the connection and they call commit(). It should fail. +import java.sql.*; +public class ConnTest17 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + if ( con == null ) + System.exit(1); + con.close(); + con.commit(); + System.exit(1); + }catch(Exception e) { + System.out.println(e.getMessage()); + e.getStackTrace(); + if (e.getMessage().equals("Invalid state")) System.exit(0); + else System.exit(1); + + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest18.java b/test/sqlnetwork/Jdbcnetwork/ConnTest18.java new file mode 100644 index 00000000..fd09600b --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest18.java @@ -0,0 +1,24 @@ +//Close the connection and then call createStatement(). It should fail. +import java.sql.*; +public class ConnTest18 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + if ( con == null ) + System.exit(1); + con.close(); + Statement cStmt = con.createStatement(); + if (cStmt != null) + System.exit(1); + }catch(Exception e) { + System.out.println(e.getMessage()); + e.getStackTrace(); + if (e.getMessage().equals("Invalid state")) System.exit(0); + else System.exit(1); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest19.java b/test/sqlnetwork/Jdbcnetwork/ConnTest19.java new file mode 100644 index 00000000..dd2b2b68 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest19.java @@ -0,0 +1,26 @@ +//Close the connection and then call preparedStatement(). It should fail +import java.sql.*; +public class ConnTest19 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + if ( con == null ) + System.exit(1); + con.close(); + PreparedStatement pStmt = null; + pStmt = con.prepareStatement("create table t1(f1 integer);"); + if (pStmt != null) + System.exit(1); + }catch(Exception e) { + System.out.println(e.getMessage()); + e.getStackTrace(); + if (e.getMessage().equals("Invalid state")) System.exit(0); + else System.exit(1); + + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest2.java b/test/sqlnetwork/Jdbcnetwork/ConnTest2.java new file mode 100755 index 00000000..79bfe9ed --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest2.java @@ -0,0 +1,18 @@ +//Connect with connect string "jdbc:csql://localhost:5678/csql" and null for username and password. It should fail. +import java.sql.*; +public class ConnTest2 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", null, null); + if (con != null) {con.close(); System.exit(1);} + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest20.java b/test/sqlnetwork/Jdbcnetwork/ConnTest20.java new file mode 100644 index 00000000..d4a677a3 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest20.java @@ -0,0 +1,23 @@ +//Open the connection and then call isClosed(). It should return false. +//Close the connection and then call isClosed(). It should return true. +import java.sql.*; +public class ConnTest20 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + if ( con == null ) + System.exit(1); + if(con.isClosed()) System.exit(1); + con.close(); + if(!con.isClosed()) System.exit(1); + }catch(Exception e) { + System.out.println(e.getMessage()); + e.getStackTrace(); + System.exit(1); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest3.java b/test/sqlnetwork/Jdbcnetwork/ConnTest3.java new file mode 100644 index 00000000..682999f9 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest3.java @@ -0,0 +1,18 @@ +//Connect only with connect string "jdbc:csql://localhost:5678/csql" and no username and password. It should fail. +import java.sql.*; +public class ConnTest3 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql"); + if (con != null) System.exit(1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest4.java b/test/sqlnetwork/Jdbcnetwork/ConnTest4.java new file mode 100644 index 00000000..43bf218b --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest4.java @@ -0,0 +1,19 @@ +//Connect with connect string "jdbc:sql://localhost:5678/csql" and give correct "user" and "password" in properties object. It should fail. + +import java.sql.*; +public class ConnTest4 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:sql://localhost:5678/csql", "root", "manager"); + if (con != null) System.exit(1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest5.java b/test/sqlnetwork/Jdbcnetwork/ConnTest5.java new file mode 100644 index 00000000..1a3fbec4 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest5.java @@ -0,0 +1,18 @@ +//Connect with connectstring "odbc:csql://localhost:5678/csql" and give correct "user" and "password" in properties object. It should fail. +import java.sql.*; +public class ConnTest5 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("odbc:csql://localhost:5678/csql", "root", "manager"); + if (con != null) System.exit(1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit (0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest6.java b/test/sqlnetwork/Jdbcnetwork/ConnTest6.java new file mode 100644 index 00000000..e65a22b8 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest6.java @@ -0,0 +1,18 @@ +//Connect with connectstring "jdbc:csql://localhost:5678/csql" and give incorrect "user" and "password" in properties object. It should fail. +import java.sql.*; +public class ConnTest6 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "wrongusertest", "manager"); + if (con != null) System.exit (1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest7.java b/test/sqlnetwork/Jdbcnetwork/ConnTest7.java new file mode 100755 index 00000000..71e004e0 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest7.java @@ -0,0 +1,18 @@ +//Connect with connectstring "jdbc:csql://localhost:5678/csql" and give correct "user" and incorrect "password" in properties object. It should fail. +import java.sql.*; +public class ConnTest7 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "wrongpasswd"); + if (con != null) System.exit(1); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest8.java b/test/sqlnetwork/Jdbcnetwork/ConnTest8.java new file mode 100644 index 00000000..d100dbbf --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest8.java @@ -0,0 +1,18 @@ +//Connect with "jdbc:csql:5678:localhost:csql" and give correct "user" and "password" in properties object. It should fail +import java.sql.*; +public class ConnTest8 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql:5678:localhost:csql", "root", "manager"); + if (con != null) {con.close(); System.exit(1);} + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/ConnTest9.java b/test/sqlnetwork/Jdbcnetwork/ConnTest9.java new file mode 100644 index 00000000..88905e18 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/ConnTest9.java @@ -0,0 +1,18 @@ +// Connect with connectstring "jdbc:csql://localhost:5678/csql" and with very long username and "password" in properties object. It should fail but no overflow +// +import java.sql.*; +public class ConnTest9 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "wrongusertiiiiiiiiiisooooooooooooooooooooooooooooooooooooooooooooooooolllllllllllllllllllllllloooooooooooooooonnnnnnnnnnnnnnnnnnnnnggggggggggggggggggggg11111111111111111111111111222222222222222222222222222222233333333333333333333333333444444444444444444444444455555555555555555555555555555556666666666666666666666666666666667777777777777777777777777777777777788888888888888888888888888888888888888899999999999999999999999999999999999999999999999999999999999999999xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiieeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeellllllllllllllllllllllllllllllllllllllllllllllllllllllliiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaannnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaatttttttttttttttttttttttttttteeeeeeeeeeeeeeeeeeeeeeeeesssssssssssssssstttttttttttttttttttttttttttttttttttttttttttttt", "manager"); + }catch(Exception e) { + System.out.println("Exception in Test: "+e.getMessage()); + e.getStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/Makefile b/test/sqlnetwork/Jdbcnetwork/Makefile new file mode 100644 index 00000000..87b5a74d --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/Makefile @@ -0,0 +1,13 @@ +OSNAME = $(shell uname -s) +JAVAC = javac +TARGETS = ConnTests +TARGETS:ConnTest1.java ConnTest2.java ConnTest3.java \ + ConnTest4.java ConnTest5.java ConnTest6.java \ + ConnTest7.java ConnTest8.java ConnTest9.java \ + ConnTest10.java ConnTest11.java ConnTest12.java ConnTest13.java \ + ConnTest14.java ConnTest15.java ConnTest16.java ConnTest17.java \ + ConnTest18.java ConnTest19.java ConnTest20.java + ${JAVAC} *.java + chmod +x *.ksh +clean: + rm -rf *.class diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest1.java b/test/sqlnetwork/Jdbcnetwork/StmtTest1.java new file mode 100644 index 00000000..bf45afb8 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest1.java @@ -0,0 +1,87 @@ +//reate a table and index for that table. Then do (INSERT/UPDATE/DELETE/SELECT) with params statement. +import java.sql.*; +public class StmtTest1 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + Statement cStmt = con.createStatement(); + cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));"); + cStmt.execute("CREATE INDEX IDX ON T1 ( f1);"); + con.commit(); + PreparedStatement stmt = null, selStmt= null; + stmt = con.prepareStatement("INSERT INTO T1 VALUES (?, ?);"); + for (int i =0 ; i< 10 ; i++) { + stmt.setInt(1, i); + stmt.setString(2, String.valueOf(i+100)); + stmt.executeUpdate(); + } + stmt.close(); + con.commit(); + selStmt = con.prepareStatement("SELECT * from T1 where f1 = ?;"); + ResultSet rs = null; + for (int i =0 ; i< 10 ; i++) { + selStmt.setInt(1, i); + rs = selStmt.executeQuery(); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + } + int ret=0; + stmt = con.prepareStatement("UPDATE T1 SET f2 = ? WHERE f1 = ?;"); + for (int i =0 ; i< 10 ; i +=2) { + stmt.setString(1, String.valueOf(i+200)); + stmt.setInt(2, i); + ret = stmt.executeUpdate(); + if (ret != 1) break; + } + stmt.close(); + con.commit(); + + System.out.println("After update, listing tuples:"); + for (int i =0 ; i< 10 ; i++) { + selStmt.setInt(1, i); + rs = selStmt.executeQuery(); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + } + con.commit(); + + + + stmt = con.prepareStatement("DELETE FROM T1 WHERE f1 = ?;"); + for (int i =0 ; i< 10 ; i +=3) { + stmt.setInt(1, i); + ret = stmt.executeUpdate(); + if (ret !=1) break; + } + stmt.close(); + con.commit(); + + System.out.println("After delete, listing tuples:"); + for (int i =0 ; i< 10 ; i++) { + selStmt.setInt(1, i); + rs = selStmt.executeQuery(); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + } + con.commit(); + cStmt.execute("DROP TABLE T1 ;"); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest10.java b/test/sqlnetwork/Jdbcnetwork/StmtTest10.java new file mode 100644 index 00000000..e9a65645 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest10.java @@ -0,0 +1,91 @@ +//Create table. At the time of insertion , Insert some record with Null Value +//Check null inserted or not +// Test For setNull() +import java.sql.*; +/** + * + * @author bijaya + */ +public class StmtTest10 { + + public static void main(String[] args) { + + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con=DriverManager.getConnection("jdbc:csql://localhost:5678/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 VALUES(?,?,?,?,?,?,?,?,?);"); + int ret=0; + for(int i=0;i<10;i++) + { + if(i==2 ) { + stmt.setNull(1,java.sql.Types.INTEGER); + stmt.setNull(2,java.sql.Types.SMALLINT); + stmt.setNull(3,java.sql.Types.TINYINT); + stmt.setNull(4,java.sql.Types.BIGINT); + stmt.setNull(5,java.sql.Types.FLOAT); + stmt.setNull(6,java.sql.Types.CHAR); + stmt.setNull(7,java.sql.Types.DATE); + stmt.setNull(8,java.sql.Types.TIME); + stmt.setNull(9,java.sql.Types.TIMESTAMP); + }else{ + stmt.setInt(1,i); + stmt.setShort(2,(short)(i+1)); + stmt.setByte(3,(byte)(i+2)); + stmt.setLong(4,(long)i); + stmt.setFloat(5,(float)1000+i); + stmt.setString(6, String.valueOf("India"+i)); + stmt.setDate(7,Date.valueOf("2008-03-21")); + stmt.setTime(8,Time.valueOf("18:00:00")); + stmt.setTimestamp(9,Timestamp.valueOf("2008-03-21 18:00:00")); + } + ret=stmt.executeUpdate(); + if(ret!=1) break; + } + stmt.close(); + con.commit(); + selStmt=con.prepareStatement("SELECT * FROM T1 ;"); + ResultSet rs=null; + selStmt.setInt(1,2); + selStmt.setShort(2,(short)3); + selStmt.setByte(3,(byte)4); + rs=selStmt.executeQuery(); + while(rs.next()) + { + + System.out.print("Tuple value is " + rs.getInt(1)+ " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.print(rs.getShort(2) + " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.print(rs.getByte(3) + " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.print(rs.getLong(4) + " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.print(rs.getFloat(5) + " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.print(rs.getString(6) + " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.print(rs.getDate(7) + " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.print(rs.getTime(8) + " "); + if(rs.wasNull()) System.out.print(" NULL"); + System.out.println(rs.getTimestamp(9) + " "); + if(rs.wasNull()) System.out.println(" NULL"); + + } + rs.close(); + con.commit(); + cStmt.executeUpdate("Drop table T1;"); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + System.exit(1); + } + + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest11.java b/test/sqlnetwork/Jdbcnetwork/StmtTest11.java new file mode 100644 index 00000000..92539755 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest11.java @@ -0,0 +1,53 @@ +//select Null test +import java.sql.*; + +/** + * + * @author bijaya + */ +public class StmtTest11{ + + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + Statement cStmt = con.createStatement(); + cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));"); + PreparedStatement stmt = null, selStmt= null; + stmt = con.prepareStatement("INSERT INTO T1 VALUES (?, NULL);"); + for (int i =0 ; i< 10 ; i++) { + stmt.setInt(1, i); + stmt.executeUpdate(); + } + stmt.close(); + con.commit(); + selStmt = con.prepareStatement("SELECT * from T1 ;"); + ResultSet rs = null; + //selStmt.setInt(1, i); + rs = selStmt.executeQuery(); + while (rs.next()) + { + int f1=rs.getInt(1); + if(rs.wasNull()) + System.out.print(" NULL"); + else + System.out.print(" "+ f1); + String f2=rs.getString(2); + if(rs.wasNull()) + System.out.println(" NULL"); + else + System.out.println(" "+ f2); + } + rs.close(); + + cStmt.executeUpdate("Drop table T1;"); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + } + } + +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest12.java b/test/sqlnetwork/Jdbcnetwork/StmtTest12.java new file mode 100644 index 00000000..8df0292b --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest12.java @@ -0,0 +1,99 @@ +//ExecuteUpdate Should return no of records updated + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; + +/** + * + * @author bijaya + */ +public class StmtTest12{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + Statement cStmt = con.createStatement(); + cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));"); + cStmt.execute("CREATE INDEX IDX ON T1 ( f1);"); + con.commit(); + PreparedStatement stmt = null, selStmt= null; + stmt = con.prepareStatement("INSERT INTO T1 VALUES (?, ?);"); + int ret=0; + for (int i =0 ; i< 10 ; i++) { + stmt.setInt(1, i); + stmt.setString(2, String.valueOf(i+100)); + ret=stmt.executeUpdate(); + if (ret != 1){ + System.out.println("ExecuteUpdate doesnot return proper values in Insert "+ret); + break; + } + System.out.println("ExecuteUpdate return proper values in Insert "); + } + stmt.close(); + con.commit(); + selStmt = con.prepareStatement("SELECT * from T1 where f1 = ?;"); + ResultSet rs = null; + for (int i =0 ; i< 10 ; i++) { + selStmt.setInt(1, i); + rs = selStmt.executeQuery(); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + } + int a=5; + stmt = con.prepareStatement("UPDATE T1 SET f2 = ? WHERE f1 >5;"); + + stmt.setString(1, String.valueOf(a+200)); + + ret = stmt.executeUpdate(); + if (ret != 4){ + System.out.println("ExecuteUpdate doesnot return proper values for Update "+ret); + } + System.out.println("ExecuteUpdate return proper values fro Update "+ret); + + stmt.close(); + con.commit(); + + System.out.println("After update, listing tuples:"); + for (int i =0 ; i< 10 ; i++) { + selStmt.setInt(1, i); + rs = selStmt.executeQuery(); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + } + con.commit(); + + stmt = con.prepareStatement("DELETE FROM T1 ;"); + + + ret = stmt.executeUpdate(); + if (ret !=10) + { + System.out.println("ExecuteUpdate doesnot return proper vslues for Delete "+ret); + } + System.out.println("ExecuteUpdate returns proper vslues for delete "+ret); + + stmt.close(); + con.commit(); + + + cStmt.execute("DROP TABLE T1 ;"); + con.close(); + }catch(Exception e) { + + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + } + } +} + diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest13.java b/test/sqlnetwork/Jdbcnetwork/StmtTest13.java new file mode 100644 index 00000000..b1e17801 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest13.java @@ -0,0 +1,58 @@ +//ExecuteUpdate for SELECT statement it should not return resultset throw exception + +import java.sql.Connection; +import java.sql.DriverManager; +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.Statement; + +/** + * + * @author bijaya + */ +public class StmtTest13 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + Statement cStmt = con.createStatement(); + cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));"); + PreparedStatement stmt = null, selStmt= null; + stmt = con.prepareStatement("INSERT INTO T1 VALUES (?, NULL);"); + for (int i =0 ; i< 10 ; i++) { + stmt.setInt(1, i); + stmt.executeUpdate(); + } + stmt.close(); + con.commit(); + selStmt = con.prepareStatement("SELECT * from T1 ;"); + ResultSet rs = null; + System.out.println("yes"); + int result = selStmt.executeUpdate(); + /* while (rs.next()) + { + int f1=rs.getInt(1); + if(rs.wasNull()) + System.out.print(" NULL"); + else + System.out.print(" "+ f1); + String f2=rs.getString(2); + if(rs.wasNull()) + System.out.println(" NULL"); + else + System.out.println(" "+ f2); + } + rs.close(); + */ + cStmt.executeUpdate("Drop table T1;"); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + System.exit(0); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest2.java b/test/sqlnetwork/Jdbcnetwork/StmtTest2.java new file mode 100644 index 00000000..fd22d7f3 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest2.java @@ -0,0 +1,61 @@ +//Create a table and index for that table. Then do (INSERT/UPDATE/DELETE/SELECT) with no params statement. +import java.sql.*; +public class StmtTest2 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + Statement cStmt = con.createStatement(); + cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));"); + cStmt.execute("CREATE INDEX IDX ON T1 ( f1);"); + con.commit(); + + cStmt.execute("INSERT INTO T1 VALUES (1, 'FIRST');"); + cStmt.executeUpdate("INSERT INTO T1 VALUES (2, 'SECOND');"); + con.commit(); + + ResultSet rs = null; + rs = cStmt.executeQuery("SELECT * from T1 where f1 = 1;"); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + + + cStmt.execute("SELECT * from T1 where f1 = 2;"); + rs = cStmt.getResultSet(); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + con.commit(); + + cStmt.executeUpdate("UPDATE T1 SET f2 = 'CHANGED' WHERE f1 = 1;"); + con.commit(); + + + + cStmt.executeUpdate("DELETE FROM T1 WHERE f1 = 2;"); + con.commit(); + + System.out.println("After delete, listing tuples:"); + rs = cStmt.executeQuery("SELECT * from T1 ;"); + while (rs.next()) + { + System.out.println("Tuple value is " + rs.getInt(1)+ " "+ rs.getString(2)); + } + rs.close(); + con.commit(); + cStmt.execute("DROP TABLE T1 ;"); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest3.java b/test/sqlnetwork/Jdbcnetwork/StmtTest3.java new file mode 100644 index 00000000..6885324c --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest3.java @@ -0,0 +1,63 @@ +//Open a connection and then close it. After that execute INSERT/QUERY/UPDATE statement. It should fail [StmtTest3.java] +import java.sql.*; +public class StmtTest3 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + Statement cStmt = con.createStatement(); + cStmt.execute("CREATE TABLE T1 (f1 integer, f2 char (20));"); + cStmt.execute("CREATE INDEX IDX ON T1 ( f1);"); + con.commit(); + con.close(); + + //after close the connection,execute "INSERT" statement,it should fail + try + { + cStmt.execute("INSERT INTO T1 VALUES (1, 'FIRST');"); + System.exit(1); + } + catch(Exception e) + { + System.out.println("insert exception---" + e.getMessage()); + } + + //after close the connection,execute "QUERY" statement,it should fail + try + { + cStmt.executeQuery("SELECT * from T1 where f1 = 1;"); + System.exit(2); + } + catch(Exception e) + { + System.out.println("query exception---" + e.getMessage()); + } + + //after close the connection,execute "UPDATE" statement,it should fail + try + { + cStmt.executeUpdate("UPDATE T1 SET f2 = 'CHANGED' WHERE f1 = 1;"); + System.exit(3); + } + catch(Exception e) + { + System.out.println("update exception---" + e.getMessage()); + } + + //cleanup + cStmt.close(); + Connection con1 = DriverManager.getConnection("jdbc:csql", "root", "manager"); + Statement cStmt1 = con1.createStatement(); + cStmt1.execute("DROP TABLE T1 ;"); + cStmt1.close(); + con1.close(); + }catch(Exception e) { + System.out.println("Exception in Test: " + e.getMessage()); + e.printStackTrace(); + System.exit(4); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest4.java b/test/sqlnetwork/Jdbcnetwork/StmtTest4.java new file mode 100644 index 00000000..b37524ca --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest4.java @@ -0,0 +1,19 @@ +//Open a connection and close it twice. It should give no error +import java.sql.*; +public class StmtTest4 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/csql", "root", "manager"); + con.close(); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + System.exit(1); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest5.java b/test/sqlnetwork/Jdbcnetwork/StmtTest5.java new file mode 100644 index 00000000..88e67a09 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest5.java @@ -0,0 +1,57 @@ +//CREATE TABLE T1 (f1 integer, f2 smallint, f3 tinyint,f4 bigint, f5 float, f6 char(10), f7 date, f8 time, f9 timestamp); +import java.sql.*; +public class StmtTest5 +{ + public static void main(String[] args) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con = DriverManager.getConnection("jdbc:csql://localhost:5678/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 VALUES (?,?,?,?,?,?,?,?,?);"); + stmt.setInt(1, 1); + stmt.setShort(2,(short)2); + stmt.setByte(3,(byte)3); + stmt.setLong(4,(long)4); + stmt.setFloat(5,(float)5); + stmt.setString(6, String.valueOf(5)); + stmt.setDate(7,Date.valueOf("2008-03-21")); + stmt.setTime(8,Time.valueOf("18:00:00")); + stmt.setTimestamp(9,Timestamp.valueOf("2008-03-21 18:00:00")); + stmt.executeUpdate(); + stmt.close(); + con.commit(); + + selStmt = con.prepareStatement("SELECT * from T1 where f1 = ?;"); + ResultSet rs = null; + + selStmt.setInt(1, 1); + 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(); + selStmt.close(); + + cStmt.execute("DROP TABLE T1 ;"); + con.close(); + }catch(Exception e) { + System.out.println("Exception in Test: "+e); + e.printStackTrace(); + } + } +} diff --git a/test/sqlnetwork/Jdbcnetwork/StmtTest6.java b/test/sqlnetwork/Jdbcnetwork/StmtTest6.java new file mode 100644 index 00000000..fcbadca1 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest6.java @@ -0,0 +1,63 @@ +//select tuple with WHERE clause having param for some fields(SELECT * FROM T1 WHERE f1=?AND f2=? AND f3=?) +import java.sql.*; +public class StmtTest6 +{ + public static void main(String[] arg) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con=DriverManager.getConnection("jdbc:csql://localhost:5678/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 VALUES(?,?,?,?,?,?,?,?,?);"); + int ret=0; + for(int i=0;i<10;i++) + { + stmt.setInt(1,i); + stmt.setShort(2,(short)(i+1)); + stmt.setByte(3,(byte)(i+2)); + stmt.setLong(4,(long)i); + stmt.setFloat(5,(float)1000+i); + stmt.setString(6, String.valueOf("Nihar"+i)); + stmt.setDate(7,Date.valueOf("2008-03-21")); + stmt.setTime(8,Time.valueOf("18:00:00")); + stmt.setTimestamp(9,Timestamp.valueOf("2008-03-21 18:00:00")); + ret=stmt.executeUpdate(); + if(ret!=1) break; + } + stmt.close(); + con.commit(); + selStmt=con.prepareStatement("SELECT * FROM T1 where f1 = ? and f2 = ? and f3 = ?"); + ResultSet rs=null; + selStmt.setInt(1,2); + selStmt.setShort(2,(short)3); + selStmt.setByte(3,(byte)4); + 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/sqlnetwork/Jdbcnetwork/StmtTest7.java b/test/sqlnetwork/Jdbcnetwork/StmtTest7.java new file mode 100644 index 00000000..7758fe39 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest7.java @@ -0,0 +1,93 @@ +//update tuple with SET and WHERE clause having params (UPDATE T1 SET f2=?, f8=? WHERE f1=?AND f9=?) +import java.sql.*; +public class StmtTest7 +{ + public static void main(String[] arg) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con=DriverManager.getConnection("jdbc:csql://localhost:5678/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 VALUES(?,?,?,?,?,?,?,?,?);"); + int ret=0; + for(int i=0;i<10;i++) + { + stmt.setInt(1,i); + stmt.setShort(2,(short)(i+1)); + stmt.setByte(3,(byte)(i+2)); + stmt.setLong(4,(long)i); + stmt.setFloat(5,(float)1000+i); + stmt.setString(6, String.valueOf("Nihar"+i)); + stmt.setDate(7,Date.valueOf("2008-03-21")); + stmt.setTime(8,Time.valueOf("18:00:00")); + stmt.setTimestamp(9,Timestamp.valueOf("2008-03-21 18:00:00")); + ret=stmt.executeUpdate(); + if(ret!=1) break; + } + 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(); + ret=0; + stmt=con.prepareStatement("UPDATE T1 SET f2=?, f8=? WHERE f1=?AND f9=?;"); + for(int i=0;i<10;i++) + { + stmt.setShort(1,(short)100); + stmt.setTime(2,Time.valueOf("19:38:25")); + stmt.setInt(3,3); + stmt.setTimestamp(4,Timestamp.valueOf("2008-03-21 18:00:00")); + ret=stmt.executeUpdate(); + if(ret!=1) break; + } + stmt.close(); + con.commit(); + selStmt=con.prepareStatement("Select * from T1"); + rs=null; + rs=selStmt.executeQuery(); + System.out.println(); + 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/sqlnetwork/Jdbcnetwork/StmtTest8.java b/test/sqlnetwork/Jdbcnetwork/StmtTest8.java new file mode 100644 index 00000000..c58ceb7e --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/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://localhost:5678/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/sqlnetwork/Jdbcnetwork/StmtTest9.java b/test/sqlnetwork/Jdbcnetwork/StmtTest9.java new file mode 100644 index 00000000..45281a0b --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/StmtTest9.java @@ -0,0 +1,93 @@ +//update tuple with SET and WHERE clause having params (UPDATE T1 SET f2=NULL, f6=NULL WHERE f1=?AND f9=?) +import java.sql.*; +public class StmtTest9 +{ + public static void main(String[] arg) + { + try + { + Class.forName("csql.jdbc.JdbcSqlDriver"); + Connection con=DriverManager.getConnection("jdbc:csql://localhost:5678/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 VALUES(?,?,?,?,?,?,?,?,?);"); + int ret=0; + for(int i=0;i<10;i++) + { + stmt.setInt(1,i); + stmt.setShort(2,(short)(i+1)); + stmt.setByte(3,(byte)(i+2)); + stmt.setLong(4,(long)i); + stmt.setFloat(5,(float)1000+i); + stmt.setString(6, String.valueOf("Nihar"+i)); + stmt.setDate(7,Date.valueOf("2008-03-21")); + stmt.setTime(8,Time.valueOf("18:00:00")); + stmt.setTimestamp(9,Timestamp.valueOf("2008-03-21 18:00:00")); + ret=stmt.executeUpdate(); + if(ret!=1) break; + } + 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(); + ret=0; + stmt=con.prepareStatement("UPDATE T1 SET f2=NULL, f5=NULL WHERE f1=?AND f9=?;"); + for(int i=0;i<10;i++) + { + //stmt.setShort(1,(short)null); + //stmt.setTime(2,null); + stmt.setInt(1,3); + stmt.setTimestamp(2,Timestamp.valueOf("2008-03-21 18:00:00")); + ret=stmt.executeUpdate(); + if(ret!=1) break; + } + stmt.close(); + con.commit(); + selStmt=con.prepareStatement("Select * from T1"); + rs=null; + rs=selStmt.executeQuery(); + System.out.println(); + 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/sqlnetwork/Jdbcnetwork/test001.ksh b/test/sqlnetwork/Jdbcnetwork/test001.ksh new file mode 100755 index 00000000..b79ffe1a --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test001.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with connect string "jdbc:csql:lllocalhost:5678/csql" and give correct "user" and "password" in properties object. It should pass. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest1 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test002.ksh b/test/sqlnetwork/Jdbcnetwork/test002.ksh new file mode 100755 index 00000000..829e0436 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test002.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with connect string "jdbc:csql:lllocalhost:5678/csql" and null for username and password. It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest2 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test003.ksh b/test/sqlnetwork/Jdbcnetwork/test003.ksh new file mode 100755 index 00000000..5a07fc7d --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test003.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Connect only with connect string "jdbc:csql://localhost:5678/csql" and no username and password. It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java -Xms256m -Xmx256m ConnTest3 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test004.ksh b/test/sqlnetwork/Jdbcnetwork/test004.ksh new file mode 100755 index 00000000..82419665 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test004.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with connect string "jdbc:sql://localhost:5678/csql" and give correct "user" and "password" in properties object. It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest4 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test005.ksh b/test/sqlnetwork/Jdbcnetwork/test005.ksh new file mode 100755 index 00000000..554647b4 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test005.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with connectstring "odbc:csql://localhost:5678/csql" and give correct "user" and "password" in properties object. It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest5 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test006.ksh b/test/sqlnetwork/Jdbcnetwork/test006.ksh new file mode 100755 index 00000000..aae6d12f --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test006.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with connectstring "jdbc:csql://localhost:5678/csql" and give incorrect "user" and "password" in properties object. It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest6 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test007.ksh b/test/sqlnetwork/Jdbcnetwork/test007.ksh new file mode 100755 index 00000000..5e38e3b8 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test007.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with connectstring "jdbc:csql://localhost:5678/csql" and give correct "user" and incorrect "password" in properties object. It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest1 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test008.ksh b/test/sqlnetwork/Jdbcnetwork/test008.ksh new file mode 100755 index 00000000..1c389999 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test008.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with "jdbc:csql:5678:localhost:csql" and give correct "user" and "password" in properties object. It should fail +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest8 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test009.ksh b/test/sqlnetwork/Jdbcnetwork/test009.ksh new file mode 100755 index 00000000..47bc5b75 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test009.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Connect with connectstring "jdbc:csql://localhost:5678/csql" and with very long username and "password" in properties object. It should fail but no overflow +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest9 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test010.ksh b/test/sqlnetwork/Jdbcnetwork/test010.ksh new file mode 100755 index 00000000..e9a30832 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test010.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Connect with "jdbc:csql://5678:localhost/csql" and give correct "user" and "password" in properties object. It should fail +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest10 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test011.ksh b/test/sqlnetwork/Jdbcnetwork/test011.ksh new file mode 100755 index 00000000..6a0fc24a --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test011.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Connect with "jdbc:csql://localhost:5678" and give correct "user" and "password" in properties object. It should pass as for csql default database is csql +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest11 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test012.ksh b/test/sqlnetwork/Jdbcnetwork/test012.ksh new file mode 100755 index 00000000..d3fec3d8 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test012.ksh @@ -0,0 +1,16 @@ +#!/bin/ksh +#Connect with "jdbc:csql://local/host:5678/csql" and give correct "user" and "password" in properties object. It should fail + +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest12 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test013.ksh b/test/sqlnetwork/Jdbcnetwork/test013.ksh new file mode 100755 index 00000000..44421584 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test013.ksh @@ -0,0 +1,16 @@ +#!/bin/ksh +#Connect with "jdbc:csql:localhost:5678" and give correct "user" and "password" in properties object. It should fail + +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest13 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test014.ksh b/test/sqlnetwork/Jdbcnetwork/test014.ksh new file mode 100755 index 00000000..c0e2625d --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test014.ksh @@ -0,0 +1,16 @@ +#!/bin/ksh +#Connect with "jdbc:csql://localhost:5678csql" and give correct "user" and "password" in properties object. It should fail + +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest14 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test015.ksh b/test/sqlnetwork/Jdbcnetwork/test015.ksh new file mode 100755 index 00000000..a36f5945 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test015.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Connect with "jdbc:csql//localhost:5678/csql" and give correct "user" and "password" in properties object. It should fail +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest15 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test016.ksh b/test/sqlnetwork/Jdbcnetwork/test016.ksh new file mode 100755 index 00000000..dfbe9c8d --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test016.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Try to open , close , open . it should pass +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest16 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test017.ksh b/test/sqlnetwork/Jdbcnetwork/test017.ksh new file mode 100755 index 00000000..ade21614 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test017.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Close the connection and they call commit(). It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest17 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test018.ksh b/test/sqlnetwork/Jdbcnetwork/test018.ksh new file mode 100755 index 00000000..8d3580b1 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test018.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Close the connection and then call createStatement(). It should fail. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest18 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test019.ksh b/test/sqlnetwork/Jdbcnetwork/test019.ksh new file mode 100755 index 00000000..c6d9358c --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test019.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Close the connection and then call preparedStatement(). It should fail +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest19 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test020.ksh b/test/sqlnetwork/Jdbcnetwork/test020.ksh new file mode 100755 index 00000000..c12ad0b2 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test020.ksh @@ -0,0 +1,16 @@ +#!/bin/ksh +#Open the connection and then call isClosed(). It should return false. +#Close the connection and then call isClosed(). It should return true. +TESTFILE=${PWD}/jdbc/Connection/ConnTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/jdbc/Connection +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java ConnTest20 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test021.ksh b/test/sqlnetwork/Jdbcnetwork/test021.ksh new file mode 100755 index 00000000..509a0823 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test021.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Create a table and index for that table. Then do (INSERT/UPDATE/DELETE/SELECT) with params statement. +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest1 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test022.ksh b/test/sqlnetwork/Jdbcnetwork/test022.ksh new file mode 100755 index 00000000..60278c2a --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test022.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Create a table and index for that table. Then do (INSERT/UPDATE/DELETE/SELECT) with no params statement. +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest2 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test023.ksh b/test/sqlnetwork/Jdbcnetwork/test023.ksh new file mode 100755 index 00000000..2fc049fc --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test023.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +#Open a connection and then close it. After that execute INSERT/QUERY/UPDATE statement. It should fail [StmtTest3.java] +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest3 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test024.ksh b/test/sqlnetwork/Jdbcnetwork/test024.ksh new file mode 100755 index 00000000..27f59ade --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test024.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# Open a connection and close it twice. It should give no error +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest4 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test025.ksh b/test/sqlnetwork/Jdbcnetwork/test025.ksh new file mode 100755 index 00000000..64deac4a --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test025.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# CREATE TABLE T1 (f1 integer, f2 smallint, f3 tinyint,f4 bigint, f5 float, f6 char(10), f7 date, f8 time, f9 timestamp); +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest5 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test026.ksh b/test/sqlnetwork/Jdbcnetwork/test026.ksh new file mode 100755 index 00000000..3d2cbbce --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test026.ksh @@ -0,0 +1,16 @@ +#!/bin/ksh +# select tuple with WHERE clause having param for some fields(SELECT * FROM T1 WHERE f1=?AND f2=? AND f3=?) +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest6.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +echo "SELECT * FROM T1 WHERE f1=?AND f2=? AND f3=?" +java StmtTest6 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test027.ksh b/test/sqlnetwork/Jdbcnetwork/test027.ksh new file mode 100755 index 00000000..1f258fd1 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test027.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# update tuple with SET and WHERE clause having params (UPDATE T1 SET f2=?, f8=? WHERE f1=?AND f9=?) +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest7.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest7 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test028.ksh b/test/sqlnetwork/Jdbcnetwork/test028.ksh new file mode 100755 index 00000000..bcd58bc9 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test028.ksh @@ -0,0 +1,15 @@ +#!/bin/ksh +# NULL Tset INSERT null values to some fields with and without parameters +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest8.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest8 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test029.ksh b/test/sqlnetwork/Jdbcnetwork/test029.ksh new file mode 100755 index 00000000..41f7b6cd --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test029.ksh @@ -0,0 +1,16 @@ +#!/bin/ksh +# update tuple with SET and WHERE clause having params (UPDATE T1 SET f2=NULL, f6=NULL WHERE f1=?AND f9=?) + +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest9.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest9 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test030.ksh b/test/sqlnetwork/Jdbcnetwork/test030.ksh new file mode 100755 index 00000000..e6af38c5 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test030.ksh @@ -0,0 +1,19 @@ +#!/bin/ksh +# Create table. At the time of insertion , Insert some record with Null Value +# Check null inserted or not +# Test For setNull() + + +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest10 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test031.ksh b/test/sqlnetwork/Jdbcnetwork/test031.ksh new file mode 100755 index 00000000..c1fef835 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test031.ksh @@ -0,0 +1,16 @@ +#!/bin/ksh +# select Null test + +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest11 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test032.ksh b/test/sqlnetwork/Jdbcnetwork/test032.ksh new file mode 100755 index 00000000..d99435bd --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test032.ksh @@ -0,0 +1,17 @@ +#!/bin/ksh +# ExecuteUpdate Should return no of records updated + + +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest12 +if [ $? -ne 0 ] +then + exit 1; +fi +exit 0; diff --git a/test/sqlnetwork/Jdbcnetwork/test033.ksh b/test/sqlnetwork/Jdbcnetwork/test033.ksh new file mode 100755 index 00000000..91adaa77 --- /dev/null +++ b/test/sqlnetwork/Jdbcnetwork/test033.ksh @@ -0,0 +1,19 @@ +#!/bin/ksh +# ExecuteUpdate for SELECT statement it should not return resultset throw exception + + +TESTFILE=${PWD}/sqlnetwork/Jdbcnetwork/StmtTest1.java +REL_PATH=. +if [ -s "$TESTFILE" ] +then + REL_PATH=`pwd`/sqlnetwork/Jdbcnetwork +fi +export CLASSPATH=$CLASSPATH:${REL_PATH} +java StmtTest13 +if [ $? -ne 0 ] +then + echo "Drop table T1;"| $CSQL_INSTALL_ROOT/bin/csql + exit 1; +fi +echo "Drop table T1;"| $CSQL_INSTALL_ROOT/bin/csql +exit 0; -- 2.11.4.GIT