我在这一行收到了这个错误:
Object[] results = (Object[])stmt.getArray(1).getArray();
不确定这意味着什么...
我也可以显示sql ...有人可以解释这个错误意味着什么......如果需要我也有那个stac跟踪
public List<SimilarItemSearchCollectBean> getSimilarItemSearchCollect(
PagerTagHelper pagerHelper,
String codes,
String params[] )
throws Exception
{
if( params.length != codes.length() ) throw new IllegalArgumentException(
"Number of codes does not match number of parameters: (" +
codes.length() + " != " + params.length + ")."
);
int i = 0;
String temp = null;
List<SimilarItemSearchCollectBean> collected = null;
String funCall = "{ call ? := " + PKG_PREFIX
+ "summarize_item_search_data( ?, ?, ?, ?, ?, ?, ?, ?, ? ) }";
OracleCallableStatement stmt = null;
try
{
java.util.Map<String,Class<?>> map = connection.getTypeMap();
map.put( schemaProvider.getSystemSchemaName()+".SIMILAR_ITEM_SEARCH_ROLLUP", SimilarItemSearchCollectBean.class );
stmt = (OracleCallableStatement)connection.prepareCall( funCall );
stmt.registerOutParameter(
1, OracleTypes.ARRAY, schemaProvider.getSystemSchemaName()+".BEAN_LIST" );
stmt.setInt( 2, pagerHelper.getStartIndex() );
stmt.setInt( 3, pagerHelper.getEndIndex() );
stmt.setObject( 4, DAOUtil.getARRAY( DAOUtil.ArrayTypes.CHAR_TAB, pagerHelper.getPropertyNames() ));
stmt.setObject( 5, DAOUtil.getARRAY( DAOUtil.ArrayTypes.CHAR_TAB, pagerHelper.getSortOrders() ));
/* Initialize all the parameters to null.
* We will re set them individually in the switch if
* there is an actual value.
*/
stmt.setString( 6, null ); // value1
stmt.setString( 7, null ); // value2
stmt.setNull( 8, OracleTypes.NUMBER ); // sac
stmt.setNull( 9, OracleTypes.NUMBER ); // job type id
stmt.setNull( 10, OracleTypes.NUMBER ); // standard unit price
// Still need to decide how searching will occur for year ranges
for( i=0; i<codes.length(); i++ )
{
if ( params[i] != null )
{
switch( codes.charAt(i) )
{
case '0': // VALUE1
temp = params[i].replace( '*', '%' );
temp = temp.replaceAll("%+", "%");
stmt.setString( 6, temp );
break;
case '1': // VALUE2
stmt.setString( 7, params[i] );
break;
case '2': // VALUE3
stmt.setInt( 8, Integer.parseInt(params[i]) );
break;
case '3': // JOB TYPE ID
stmt.setLong( 9, Long.parseLong( params[i] ) );
break;
case '4': // VALUE4
stmt.setLong( 10, Long.parseLong(params[i]));
break;
default:
} // end switch
} // if not null
} // end for
stmt.execute();
// ERROR HERE:
Object[] results = (Object[])stmt.getArray(1).getArray();
collected = new ArrayList<SimilarItemSearchCollectBean>();
for( i=0; i<results.length; i++ )
collected.add( (SimilarItemSearchCollectBean)results[i] );
} // end try
finally { close( stmt ); }
return collected;
} // end
答案 0 :(得分:1)
不熟悉OracleCallableStatement
,但不应该
Object[] results = (Object[])(stmt.getARRAY(1).getArray());
oracle.jdbc.OracleCallableStatement#getARRAY(int)
是OracleCallableStatement
- 具体,getArray()
似乎是从java.sql.CallableStatement#getArray(int)
继承的。
我已经说过我对此并不熟悉,但getARRAY
似乎更适合您注册为out参数的OracleTypes.ARRAY
类型。