|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.softtech.jdbc.SampleCodeUsingFramework
public class SampleCodeUsingFramework
This class contains static methods for testing the JDBC framework code.
| Field Summary | |
|---|---|
private static java.lang.String |
connURL
JDBC connection URL |
private static java.lang.String |
driverName
JDBC driver name |
private static java.lang.String |
password
JDBC connection password |
(package private) static java.lang.String |
sqlSelect
select statement used by some test methods |
private static java.lang.String |
username
JDBC connection username |
| Constructor Summary | |
|---|---|
SampleCodeUsingFramework()
|
|
| Method Summary | |
|---|---|
private static void |
applyDataIntegrityViolationRecovery()
Dummy method (placeholder) for recovery method |
static ConnectionPool |
getConnectionPool()
Creates a new connection pool object |
static void |
main(java.lang.String[] args)
static main method testing jdbc framework with various method calls |
private static void |
setHSQLConnectInfo()
Sets fields to values required to connect to a sample HSQL database |
private static void |
setMySQLConnectInfo()
Sets fields to values required to connect to a sample MySQL database |
private static void |
setOracleConnectInfo()
Sets fields to values required to connect to a sample ORACLE database |
private static void |
setPostgreSQLConnectInfo()
Sets fields to values required to connect to a sample PostgreSQL database |
static void |
testCallingStoredProc()
This procecure calls the following Oracle stored procedure which inserts a new row into the JDBC_TEST table. |
static void |
testCallingStoredProcWithAnOUTParam()
This procedure calls the following Oracle stored procedure and gets the value from the OUT param pFULLNAME. |
static void |
testConnectionPooling()
Creates a connection pool (2 connections) and execututes queries on each. |
static void |
testCreatingOwnConnection()
Illustrates creating a database connection using standard JDBC and then using this connection to create a ConnectionPool and execute a select statement. |
static void |
testDeadlockException()
static method testing jdbc framework with a select for update statement (that locks a record) and an update statement that generates a deadlock. |
static void |
testDeleteAndInsert()
static method testing jdbc framework with a delete and an insert statement |
static void |
testHSQL()
|
static void |
testMultipleUpdatesAndTrans()
static method testing jdbc framework with multiple updates, using transaction management |
static void |
testMultipleUpdatesAndTransWithException()
static method testing jdbc framework with multiple updates and intentional sql exceptions that are trapped in appropriate exception handling blocks |
static void |
testMySQL()
Does a simple select from a MySQL database. |
static void |
testOracleStoredFunction()
This method tests the jdbc framework with a call to the following Oracle stored function: CREATE OR REPLACE FUNCTION jdbc_test1 RETURN NUMBER IS cnt_jdbc_test NUMBER; BEGIN dbms_output.put_line ('starting jdbc_test1...'); cnt_jdbc_test := 0; SELECT COUNT(*) INTO cnt_jdbc_test FROM JDBC_TEST; RETURN cnt_jdbc_test; EXCEPTION WHEN NO_DATA_FOUND THEN Null; WHEN OTHERS THEN -- Consider logging the error and then re-raise RAISE; END jdbc_test1; / |
static void |
testParameterizedQuery()
Run a parameterized query (sql) once with one parameter and then again with another parameter. |
static void |
testSelectDistinctAndMixedCase()
|
static void |
testSelectWhichReturnsNoRows()
static method testing jdbc framework with a simple select statement that returns no rows |
static void |
testSimpleSelectAndMaxRows()
static method testing jdbc framework with a simple select statement, parameters, and a maximum number of rows |
static void |
testSimpleSelectWithParams()
static method testing jdbc framework with a simple select statement using parameters |
static void |
testSimpleSelectWithParamsAndToString()
static method testing jdbc framework with a simple select statement using parameters and the result set's .toString() method |
static void |
testStandardJDBC()
static method executes a standard jdbc query |
static void |
testThis()
|
static void |
testUpdate()
static method testing jdbc framework with an update statement |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static java.lang.String driverName
private static java.lang.String connURL
private static java.lang.String username
private static java.lang.String password
static java.lang.String sqlSelect
| Constructor Detail |
|---|
public SampleCodeUsingFramework()
| Method Detail |
|---|
private static void setMySQLConnectInfo()
private static void setPostgreSQLConnectInfo()
private static void setOracleConnectInfo()
private static void setHSQLConnectInfo()
private static void applyDataIntegrityViolationRecovery()
public static void testStandardJDBC()
public static ConnectionPool getConnectionPool()
public static void testSimpleSelectWithParams()
public static void testSimpleSelectWithParamsAndToString()
public static void testSimpleSelectAndMaxRows()
public static void testOracleStoredFunction()
public static void testDeleteAndInsert()
public static void testUpdate()
public static void testMultipleUpdatesAndTrans()
public static void testMultipleUpdatesAndTransWithException()
public static void testSelectWhichReturnsNoRows()
public static void testDeadlockException()
public static void testCreatingOwnConnection()
public static void testMySQL()
public static void testConnectionPooling()
public static void testSelectDistinctAndMixedCase()
public static void testCallingStoredProc()
public static void testCallingStoredProcWithAnOUTParam()
public static void testParameterizedQuery()
public static void testThis()
public static void testHSQL()
public static void main(java.lang.String[] args)
args -
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||