Author: stliu
Date: 2009-12-21 12:51:13 -0500 (Mon, 21 Dec 2009)
New Revision: 18308
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle8iDialect.java
Log:
JBPAPP-3211 HHH-3159 - Oracle 11g - desupport of oracle.jdbc.driver
Modified:
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle8iDialect.java
===================================================================
---
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle8iDialect.java 2009-12-21
17:18:14 UTC (rev 18307)
+++
core/branches/Branch_3_2_4_SP1_CP/src/org/hibernate/dialect/Oracle8iDialect.java 2009-12-21
17:51:13 UTC (rev 18308)
@@ -357,24 +357,52 @@
}
};
+
+ public static final String ORACLE_TYPES_CLASS_NAME =
"oracle.jdbc.OracleTypes";
+ public static final String DEPRECATED_ORACLE_TYPES_CLASS_NAME =
"oracle.jdbc.driver.OracleTypes";
+ public static final int INIT_ORACLETYPES_CURSOR_VALUE = -99;
+
// not final-static to avoid possible classcast exceptions if using different oracle
drivers.
- int oracletypes_cursor_value = 0;
- public int registerResultSetOutParameter(java.sql.CallableStatement statement,int col)
throws SQLException {
- if(oracletypes_cursor_value==0) {
+ private int oracleCursorTypeSqlType = INIT_ORACLETYPES_CURSOR_VALUE;
+
+ public int getOracleCursorTypeSqlType() {
+ if ( oracleCursorTypeSqlType == INIT_ORACLETYPES_CURSOR_VALUE ) {
+ // todo : is there really any reason to keep trying if this fails once?
+ oracleCursorTypeSqlType = extractOracleCursorTypeValue();
+ }
+ return oracleCursorTypeSqlType;
+ }
+
+ protected int extractOracleCursorTypeValue() {
+ Class oracleTypesClass;
+ try {
+ oracleTypesClass = ReflectHelper.classForName( ORACLE_TYPES_CLASS_NAME );
+ }
+ catch ( ClassNotFoundException cnfe ) {
try {
- Class types =
ReflectHelper.classForName("oracle.jdbc.driver.OracleTypes");
- oracletypes_cursor_value =
types.getField("CURSOR").getInt(types.newInstance());
- } catch (Exception se) {
- throw new HibernateException("Problem while trying to load or access
OracleTypes.CURSOR value",se);
+ oracleTypesClass = ReflectHelper.classForName( DEPRECATED_ORACLE_TYPES_CLASS_NAME );
}
+ catch ( ClassNotFoundException e ) {
+ throw new HibernateException( "Unable to locate OracleTypes class", e );
+ }
}
+
+ try {
+ return oracleTypesClass.getField( "CURSOR" ).getInt( null );
+ }
+ catch ( Exception se ) {
+ throw new HibernateException( "Unable to access OracleTypes.CURSOR value",
se );
+ }
+ }
+
+ public int registerResultSetOutParameter(CallableStatement statement, int col) throws
SQLException {
// register the type of the out param - an Oracle specific type
- statement.registerOutParameter(col, oracletypes_cursor_value);
+ statement.registerOutParameter( col, getOracleCursorTypeSqlType() );
col++;
return col;
}
-
+
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
ps.execute();
return ( ResultSet ) ps.getObject( 1 );