org.apache.derbyTesting.functionTests.tests.jdbcapi
Class ParameterMappingTest

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by org.apache.derbyTesting.junit.BaseTestCase
              extended by org.apache.derbyTesting.junit.BaseJDBCTestCase
                  extended by org.apache.derbyTesting.functionTests.tests.jdbcapi.ParameterMappingTest
All Implemented Interfaces:
junit.framework.Test

public class ParameterMappingTest
extends BaseJDBCTestCase


Field Summary
private static boolean _
           
static boolean[][] allowRegisterOut
           
static boolean[][] B2_MOD
          JDBC 3.0 Section 13.2.2.1 specifies that table B-2 is used to specify type mappings from the Java types (e.g. int as setInt) to the JDBC SQL Type (Types.INT).
private static java.lang.Class[] B3_GET_OBJECT
           
static boolean[][] B5
          Table B5 conversion of Objects using setObject
static boolean[][] B6
          JDBC 3.0 spec Table B6 - Use of ResultSet getter Methods to Retrieve JDBC Data Types
private static boolean HAVE_BIG_DECIMAL
           
private static int[] jdbcTypes
           
private static java.lang.String[] SQLTypes
           
private static java.lang.String[] validString
           
private static boolean X
           
 
Fields inherited from class org.apache.derbyTesting.junit.BaseTestCase
DEFAULT_DB_DIR, DERBY_LOG, ERRORSTACKTRACEFILE
 
Constructor Summary
ParameterMappingTest(java.lang.String arg0)
           
 
Method Summary
private static java.lang.String checkForInvalidConversion(java.sql.SQLException sqle)
          Look for an "Invalid Conversion" exception and format it for display.
private static void checkProcedureOutput(int param, int paramType, byte val)
           
private static void checkProcedureOutput(int param, int paramType, byte[] val)
           
private static void checkProcedureOutput(int param, int paramType, java.sql.Date val)
           
private static void checkProcedureOutput(int param, int paramType, double val)
           
private static void checkProcedureOutput(int param, int paramType, float val)
           
private static void checkProcedureOutput(int param, int paramType, int val)
           
private static void checkProcedureOutput(int param, int paramType, long val)
           
private static void checkProcedureOutput(int param, int paramType, short val)
           
private static void checkProcedureOutput(int param, int paramType, java.lang.String val)
           
private static void checkProcedureOutput(int param, int paramType, java.sql.Time val)
           
private static void checkProcedureOutput(int param, int paramType, java.sql.Timestamp val)
           
private static void checkValidStringValue(java.lang.String method, java.lang.String s)
           
(package private) static void dumpSQLExceptions(java.sql.SQLException se)
           
private static boolean getOutValue(java.sql.CallableStatement cs, int param, int regJdbcType, int paramType)
           
private static boolean getValidValue(java.sql.PreparedStatement ps, int jdbcType, java.lang.String method)
           
private static void getXXX(java.sql.PreparedStatement ps, int type, boolean isNull)
           
private static boolean isBooleanMethod(java.lang.String method)
           
private static void judge_getXXX(boolean worked, java.sql.SQLException sqleResult, int whichCall, int type)
           
private static void judge_setObject(boolean worked, java.sql.SQLException sqleResult, int b5o, int type)
           
private static void judge_setXXX(boolean worked, java.sql.SQLException sqleResult, int whichCall, int type)
           
static void pmap(java.math.BigDecimal in, java.math.BigDecimal[] inout, java.math.BigDecimal[] out)
           
static void pmap(byte[] in, byte[][] inout, byte[][] out)
           
static void pmap(java.sql.Date in, java.sql.Date[] inout, java.sql.Date[] out)
           
static void pmap(double in, double[] inout, double[] out)
           
static void pmap(float in, float[] inout, float[] out)
           
static void pmap(int in, int[] inout, int[] out)
           
static void pmap(long in, long[] inout, long[] out)
           
static void pmap(short in, short[] inout, short[] out)
           
static void pmap(java.lang.String in, java.lang.String[] inout, java.lang.String[] out)
           
static void pmap(java.sql.Timestamp in, java.sql.Timestamp[] inout, java.sql.Timestamp[] out)
           
static void pmap(java.sql.Time in, java.sql.Time[] inout, java.sql.Time[] out)
           
protected  void setUp()
           
private static boolean setValidValue(java.sql.PreparedStatement ps, int param, int jdbcType)
           
private static void setXXX_setObject(java.sql.Statement s, java.sql.PreparedStatement psi, java.sql.PreparedStatement psq, int type, java.lang.Object value, java.lang.String className, int b5o)
           
private static void setXXX(java.sql.Statement s, java.sql.PreparedStatement psi, java.sql.PreparedStatement psq, int type)
           
private static void showException(java.sql.SQLException sqle)
           
private static java.lang.String showFirstTwo(byte[] data)
           
private static java.lang.String showFirstTwo(java.io.InputStream in)
           
private static java.lang.String showFirstTwo(java.io.Reader in)
           
private static boolean specificCheck(java.sql.ResultSet rs, boolean worked, java.sql.SQLException sqleResult, boolean isNull)
           
static junit.framework.Test suite()
           
protected  void tearDown()
          Tear down this fixture, sub-classes should call super.tearDown().
 void testDerby2073()
          Test setBigDecimal does not lose fractional digits
 void testParameterMapping()
           
private static void testSetStringInvalidValue(int type, java.sql.PreparedStatement psi)
          Test for DERBY-149 fix Check that setString to an invalid value throws an exception rather than causing a hang
private static void unexpectedException(java.sql.SQLException sqle)
           
 
Methods inherited from class org.apache.derbyTesting.junit.BaseJDBCTestCase
assertCallError, assertCheckTable, assertCompileError, assertEquals, assertEquals, assertEquals, assertEquivalentDataType, assertGetIntError, assertNextError, assertPreparedStatementError, assertSQLExceptionEquals, assertSQLState, assertSQLState, assertStatementError, assertStatementError, assertStatementError, assertStatementError, assertTableRowCount, assertUpdateCount, assertUpdateCount, checkAllConsistency, checkEstimatedRowCount, commit, createStatement, createStatement, createStatement, dropTable, dropTable, getConnection, getDatabaseProperty, getLastSQLException, initializeConnection, openConnection, openDefaultConnection, openDefaultConnection, openUserConnection, prepareCall, prepareCall, prepareCall, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, prepareStatement, rollback, runScript, runScript, runSQLCommands, setAutoCommit, usingDB2Client, usingDerbyNetClient, usingEmbedded
 
Methods inherited from class org.apache.derbyTesting.junit.BaseTestCase
alarm, assertEquals, assertEquals, assertEquals, assertExecJavaCmdAsExpected, assertSecurityManager, assertThrowableEquals, execJavaCmd, fail, getFailureFolder, getJavaExecutableName, getSystemProperty, getTestConfiguration, getTestResource, openTestResource, println, printStackTrace, readProcessOutput, removeDirectory, removeDirectory, removeSystemProperty, runBare, setSystemProperty, traceit
 
Methods inherited from class junit.framework.TestCase
countTestCases, createResult, getName, run, run, runTest, setName, toString
 
Methods inherited from class junit.framework.Assert
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, fail, fail
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

HAVE_BIG_DECIMAL

private static boolean HAVE_BIG_DECIMAL

jdbcTypes

private static int[] jdbcTypes

SQLTypes

private static java.lang.String[] SQLTypes

validString

private static java.lang.String[] validString

B3_GET_OBJECT

private static java.lang.Class[] B3_GET_OBJECT

_

private static final boolean _
See Also:
Constant Field Values

X

private static final boolean X
See Also:
Constant Field Values

B6

public static final boolean[][] B6
JDBC 3.0 spec Table B6 - Use of ResultSet getter Methods to Retrieve JDBC Data Types


B2_MOD

public static boolean[][] B2_MOD
JDBC 3.0 Section 13.2.2.1 specifies that table B-2 is used to specify type mappings from the Java types (e.g. int as setInt) to the JDBC SQL Type (Types.INT). This table does not include stream methods and does not include conversions specified elsewhere in the text, Namely Section 16.3.2 setBinaryStream may be used to set a BLOB setAsciiStream and setCharacterStream may be used to set a CLOB Thus this B2_MOD table is laid out like the B6 table and makes the assumptions that - Any Java numeric type can be used to set any SQL numeric type - Any Java numeric type can be used to set any SQL CHAR type - Numeric and date/time java types can be converted to SQL Char values.


B5

public static boolean[][] B5
Table B5 conversion of Objects using setObject


allowRegisterOut

public static final boolean[][] allowRegisterOut
Constructor Detail

ParameterMappingTest

public ParameterMappingTest(java.lang.String arg0)
Parameters:
arg0 -
Method Detail

setUp

protected void setUp()
              throws java.lang.Exception
Overrides:
setUp in class junit.framework.TestCase
Throws:
java.lang.Exception

testDerby2073

public void testDerby2073()
                   throws java.lang.Exception
Test setBigDecimal does not lose fractional digits

Throws:
java.lang.Exception

testParameterMapping

public void testParameterMapping()
                          throws java.lang.Exception
Throws:
java.lang.Exception

tearDown

protected void tearDown()
                 throws java.lang.Exception
Description copied from class: BaseJDBCTestCase
Tear down this fixture, sub-classes should call super.tearDown(). This cleanups & closes the connection if it is open and any statement objects returned through the utility methods.

Overrides:
tearDown in class BaseJDBCTestCase
Throws:
java.lang.Exception

getXXX

private static void getXXX(java.sql.PreparedStatement ps,
                           int type,
                           boolean isNull)
                    throws java.sql.SQLException,
                           java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

specificCheck

private static boolean specificCheck(java.sql.ResultSet rs,
                                     boolean worked,
                                     java.sql.SQLException sqleResult,
                                     boolean isNull)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

judge_getXXX

private static void judge_getXXX(boolean worked,
                                 java.sql.SQLException sqleResult,
                                 int whichCall,
                                 int type)

judge_setXXX

private static void judge_setXXX(boolean worked,
                                 java.sql.SQLException sqleResult,
                                 int whichCall,
                                 int type)

judge_setObject

private static void judge_setObject(boolean worked,
                                    java.sql.SQLException sqleResult,
                                    int b5o,
                                    int type)

checkForInvalidConversion

private static java.lang.String checkForInvalidConversion(java.sql.SQLException sqle)
Look for an "Invalid Conversion" exception and format it for display. Look for an "Invalid Conversion" exception. If one is found, print "IC". If one is not found, dump the actual exception to the output instead. Note that the actual invalid conversion exception may be wrapped inside a BatchUpdateException, so we may need to hunt through the exception chain to find it.


setXXX

private static void setXXX(java.sql.Statement s,
                           java.sql.PreparedStatement psi,
                           java.sql.PreparedStatement psq,
                           int type)
                    throws java.sql.SQLException,
                           java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

setXXX_setObject

private static void setXXX_setObject(java.sql.Statement s,
                                     java.sql.PreparedStatement psi,
                                     java.sql.PreparedStatement psq,
                                     int type,
                                     java.lang.Object value,
                                     java.lang.String className,
                                     int b5o)
                              throws java.sql.SQLException,
                                     java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

unexpectedException

private static void unexpectedException(java.sql.SQLException sqle)

showException

private static void showException(java.sql.SQLException sqle)

setValidValue

private static boolean setValidValue(java.sql.PreparedStatement ps,
                                     int param,
                                     int jdbcType)
                              throws java.sql.SQLException
Throws:
java.sql.SQLException

getValidValue

private static boolean getValidValue(java.sql.PreparedStatement ps,
                                     int jdbcType,
                                     java.lang.String method)
                              throws java.sql.SQLException,
                                     java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

checkValidStringValue

private static void checkValidStringValue(java.lang.String method,
                                          java.lang.String s)

isBooleanMethod

private static boolean isBooleanMethod(java.lang.String method)

getOutValue

private static boolean getOutValue(java.sql.CallableStatement cs,
                                   int param,
                                   int regJdbcType,
                                   int paramType)
                            throws java.sql.SQLException,
                                   java.io.IOException
Throws:
java.sql.SQLException
java.io.IOException

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         byte val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         short val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         int val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         long val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         float val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         double val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         java.lang.String val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         byte[] val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         java.sql.Date val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         java.sql.Time val)

checkProcedureOutput

private static void checkProcedureOutput(int param,
                                         int paramType,
                                         java.sql.Timestamp val)

dumpSQLExceptions

static void dumpSQLExceptions(java.sql.SQLException se)

testSetStringInvalidValue

private static void testSetStringInvalidValue(int type,
                                              java.sql.PreparedStatement psi)
Test for DERBY-149 fix Check that setString to an invalid value throws an exception rather than causing a hang

Parameters:
type - type for SQLTypes array
psi - - insert prepared statement.

showFirstTwo

private static java.lang.String showFirstTwo(java.io.Reader in)
                                      throws java.io.IOException
Throws:
java.io.IOException

showFirstTwo

private static java.lang.String showFirstTwo(java.io.InputStream in)
                                      throws java.io.IOException
Throws:
java.io.IOException

showFirstTwo

private static java.lang.String showFirstTwo(byte[] data)

suite

public static junit.framework.Test suite()

pmap

public static void pmap(short in,
                        short[] inout,
                        short[] out)

pmap

public static void pmap(int in,
                        int[] inout,
                        int[] out)

pmap

public static void pmap(long in,
                        long[] inout,
                        long[] out)

pmap

public static void pmap(float in,
                        float[] inout,
                        float[] out)

pmap

public static void pmap(double in,
                        double[] inout,
                        double[] out)

pmap

public static void pmap(byte[] in,
                        byte[][] inout,
                        byte[][] out)

pmap

public static void pmap(java.sql.Date in,
                        java.sql.Date[] inout,
                        java.sql.Date[] out)

pmap

public static void pmap(java.sql.Time in,
                        java.sql.Time[] inout,
                        java.sql.Time[] out)

pmap

public static void pmap(java.sql.Timestamp in,
                        java.sql.Timestamp[] inout,
                        java.sql.Timestamp[] out)

pmap

public static void pmap(java.lang.String in,
                        java.lang.String[] inout,
                        java.lang.String[] out)

pmap

public static void pmap(java.math.BigDecimal in,
                        java.math.BigDecimal[] inout,
                        java.math.BigDecimal[] out)

Built on Thu 2009-11-26 18:42:53-0800, from revision 884739

Apache Derby V10.6 Internals - Copyright © 2004,2008 The Apache Software Foundation. All Rights Reserved.