You are viewing a plain text version of this content. The canonical link for it is here.
Posted to ojb-dev@db.apache.org by ar...@apache.org on 2003/12/09 20:24:02 UTC
cvs commit: db-ojb/src/java/org/apache/ojb/broker/util JdbcTypesHelper.java
arminw 2003/12/09 11:24:02
Modified: src/java/org/apache/ojb/broker/metadata JdbcType.java
src/java/org/apache/ojb/broker/util JdbcTypesHelper.java
Log:
make compatible with jdk <1.4x
avoid CallableStatement#get(Type)(String columnName) method calls
introduced for stored procedures support, but I think we don't need them.
Revision Changes Path
1.2 +4 -2 db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcType.java
Index: JdbcType.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/metadata/JdbcType.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JdbcType.java 9 Dec 2003 17:19:58 -0000 1.1
+++ JdbcType.java 9 Dec 2003 19:24:02 -0000 1.2
@@ -28,7 +28,9 @@
* Returns an java object for this jdbc type by extract from the given
* CallableStatement or ResultSet.
* <br/>
- * NOTE: Exactly one of the arguments of type CallableStatement or ResultSet
+ * NOTE: For internal use only!!
+ * <br/>
+ * Exactly one of the arguments of type CallableStatement or ResultSet
* have to be non-null. If the 'columnId' argument is equals {@link #MIN_INT}, then the given 'columnName'
* argument is used to lookup column. Else the given 'columnId' is used as column index.
*/
1.2 +130 -119 db-ojb/src/java/org/apache/ojb/broker/util/JdbcTypesHelper.java
Index: JdbcTypesHelper.java
===================================================================
RCS file: /home/cvs/db-ojb/src/java/org/apache/ojb/broker/util/JdbcTypesHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JdbcTypesHelper.java 9 Dec 2003 17:19:58 -0000 1.1
+++ JdbcTypesHelper.java 9 Dec 2003 19:24:02 -0000 1.2
@@ -296,8 +296,11 @@
{
abstract Object readValueFromResultSet(ResultSet rs, String columnName) throws SQLException;
abstract Object readValueFromResultSet(ResultSet rs, int columnIndex) throws SQLException;
- abstract Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException;
abstract Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException;
+ /*
+ only supported by jdk >= 1.4x, maybe useful in further versions
+ */
+ // abstract Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException;
public Object getObjectFromColumn(CallableStatement stmt, int columnId) throws SQLException
{
@@ -314,8 +317,16 @@
{
if (stmt != null)
{
- return columnIndex == MIN_INT
- ? readValueFromStatement(stmt, columnName) : readValueFromStatement(stmt, columnIndex);
+// return columnIndex == MIN_INT
+// ? readValueFromStatement(stmt, columnName) : readValueFromStatement(stmt, columnIndex);
+ if(columnIndex == MIN_INT)
+ {
+ throw new UnsupportedOperationException("Not implemented yet");
+ }
+ else
+ {
+ return readValueFromStatement(stmt, columnIndex);
+ }
}
else
{
@@ -351,10 +362,10 @@
return identifier.toString();
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getString(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getString(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -384,10 +395,10 @@
return identifier.toString();
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getString(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getString(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -417,10 +428,10 @@
return identifier.toString();
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getString(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getString(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -450,10 +461,10 @@
return new BigDecimal(identifier.longValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getBigDecimal(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getBigDecimal(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -483,10 +494,10 @@
return new BigDecimal(identifier.longValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getBigDecimal(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getBigDecimal(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -516,11 +527,11 @@
throw new SequenceManagerException("Not supported sequence key type 'BIT'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- boolean temp = stmt.getBoolean(columnName);
- return (stmt.wasNull() ? null : new Boolean(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// boolean temp = stmt.getBoolean(columnName);
+// return (stmt.wasNull() ? null : new Boolean(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -554,11 +565,11 @@
throw new SequenceManagerException("Not supported sequence key type 'BOOLEAN'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- boolean temp = stmt.getBoolean(columnName);
- return (stmt.wasNull() ? null : BooleanUtils.toBooleanObject(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// boolean temp = stmt.getBoolean(columnName);
+// return (stmt.wasNull() ? null : BooleanUtils.toBooleanObject(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -592,11 +603,11 @@
return new Byte(identifier.byteValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- byte temp = stmt.getByte(columnName);
- return (stmt.wasNull() ? null : new Byte(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// byte temp = stmt.getByte(columnName);
+// return (stmt.wasNull() ? null : new Byte(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -629,11 +640,11 @@
return new Short(identifier.shortValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- short temp = stmt.getShort(columnName);
- return (stmt.wasNull() ? null : new Short(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// short temp = stmt.getShort(columnName);
+// return (stmt.wasNull() ? null : new Short(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -666,11 +677,11 @@
return new Integer(identifier.intValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- int temp = stmt.getInt(columnName);
- return (stmt.wasNull() ? null : new Integer(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// int temp = stmt.getInt(columnName);
+// return (stmt.wasNull() ? null : new Integer(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -703,11 +714,11 @@
return identifier;
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- long temp = stmt.getLong(columnName);
- return (stmt.wasNull() ? null : new Long(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// long temp = stmt.getLong(columnName);
+// return (stmt.wasNull() ? null : new Long(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -740,11 +751,11 @@
return new Float(identifier.floatValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- float temp = stmt.getFloat(columnName);
- return (stmt.wasNull() ? null : new Float(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// float temp = stmt.getFloat(columnName);
+// return (stmt.wasNull() ? null : new Float(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -777,11 +788,11 @@
return new Double(identifier.doubleValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- double temp = stmt.getDouble(columnName);
- return (stmt.wasNull() ? null : new Double(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// double temp = stmt.getDouble(columnName);
+// return (stmt.wasNull() ? null : new Double(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -814,11 +825,11 @@
return new Double(identifier.doubleValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- double temp = stmt.getDouble(columnName);
- return (stmt.wasNull() ? null : new Double(temp));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// double temp = stmt.getDouble(columnName);
+// return (stmt.wasNull() ? null : new Double(temp));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -851,10 +862,10 @@
return identifier.toString().getBytes();
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getBytes(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getBytes(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -884,10 +895,10 @@
return identifier.toString().getBytes();
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getBytes(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getBytes(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -917,10 +928,10 @@
return identifier.toString().getBytes();
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getBytes(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getBytes(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -950,10 +961,10 @@
return new Date(identifier.longValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getDate(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getDate(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -983,10 +994,10 @@
return new Time(identifier.longValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getTime(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getTime(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -1016,10 +1027,10 @@
return new Timestamp(identifier.longValue());
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getTimestamp(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getTimestamp(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -1049,11 +1060,11 @@
throw new SequenceManagerException("Not supported sequence key type 'CLOB'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- Clob aClob = stmt.getClob(columnName);
- return (stmt.wasNull() ? null : aClob.getSubString(1L, (int) aClob.length()));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// Clob aClob = stmt.getClob(columnName);
+// return (stmt.wasNull() ? null : aClob.getSubString(1L, (int) aClob.length()));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -1086,11 +1097,11 @@
throw new SequenceManagerException("Not supported sequence key type 'BLOB'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- Blob aBlob = stmt.getBlob(columnName);
- return (stmt.wasNull() ? null : aBlob.getBytes(1L, (int) aBlob.length()));
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// Blob aBlob = stmt.getBlob(columnName);
+// return (stmt.wasNull() ? null : aBlob.getBytes(1L, (int) aBlob.length()));
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -1123,10 +1134,10 @@
throw new SequenceManagerException("Not supported sequence key type 'ARRAY'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getArray(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getArray(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -1156,10 +1167,10 @@
throw new SequenceManagerException("Not supported sequence key type 'STRUCT'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getObject(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getObject(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -1189,10 +1200,10 @@
throw new SequenceManagerException("Not supported sequence key type 'REF'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getRef(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getRef(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
@@ -1223,10 +1234,10 @@
throw new SequenceManagerException("Not supported sequence key type 'DATALINK'");
}
- Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
- {
- return stmt.getURL(columnName);
- }
+// Object readValueFromStatement(CallableStatement stmt, String columnName) throws SQLException
+// {
+// return stmt.getURL(columnName);
+// }
Object readValueFromStatement(CallableStatement stmt, int columnIndex) throws SQLException
{
---------------------------------------------------------------------
To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org