Here you can find the source of getCallableStatementValue(CallableStatement cstm, int index)
Parameter | Description |
---|---|
cstm | the cstm |
index | the index |
Parameter | Description |
---|---|
SQLException | the sQL exception |
public static Object getCallableStatementValue(CallableStatement cstm, int index) throws SQLException
//package com.java2s; import java.sql.Blob; import java.sql.CallableStatement; import java.sql.Clob; import java.sql.SQLException; public class Main { /**/*from www . ja v a 2 s. co m*/ * Gets the callable statement value. * * @param cstm * the cstm * @param index * the index * @return the callable statement value * @throws SQLException * the sQL exception */ public static Object getCallableStatementValue(CallableStatement cstm, int index) throws SQLException { Object obj = cstm.getObject(index); if (obj instanceof Blob) { obj = cstm.getBytes(index); } else if (obj instanceof Clob) { obj = cstm.getString(index); } else if (obj != null && obj.getClass().getName().startsWith("oracle.sql.TIMESTAMP")) { obj = cstm.getTimestamp(index); } else if (obj != null && obj.getClass().getName().startsWith("oracle.sql.DATE")) { String metaDataClassName = cstm.getMetaData().getColumnClassName(index); if ("java.sql.Timestamp".equals(metaDataClassName) || "oracle.sql.TIMESTAMP".equals(metaDataClassName)) { obj = cstm.getTimestamp(index); } else { obj = cstm.getDate(index); } } else if (obj != null && obj instanceof java.sql.Date) { if ("java.sql.Timestamp".equals(cstm.getMetaData().getColumnClassName(index))) { obj = cstm.getTimestamp(index); } } return obj; } /** * Gets the callable statement value. * * @param cstm * the cstm * @param name * the name * @return the callable statement value * @throws SQLException * the sQL exception */ public static Object getCallableStatementValue(CallableStatement cstm, String name) throws SQLException { Object obj = cstm.getObject(name); if (obj instanceof Blob) { obj = cstm.getBytes(name); } else if (obj instanceof Clob) { obj = cstm.getString(name); } else if (obj != null) { if (obj instanceof java.sql.Timestamp || "java.sql.Timestamp".equals(obj.getClass().getName())) { obj = cstm.getTimestamp(name); } else if (obj.getClass().getName().startsWith("oracle.sql.TIMESTAMP")) { obj = cstm.getTimestamp(name); } else if (obj instanceof java.sql.Date || "java.sql.Date".equals(obj.getClass().getName())) { obj = cstm.getDate(name); } } return obj; } }