sunflower_rahul 0 Newbie Poster

Hi to All ,
I am getting this type of error while running the Sql through JDBC.

java.sql.SQLException: Invalid column index
java.sql.SQLException: Invalid column index
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
at oracle.jdbc.driver.OraclePreparedStatement.setIntInternal(OraclePreparedStatement.java:4635)
at oracle.jdbc.driver.OraclePreparedStatement.setInt(OraclePreparedStatement.java:4627)
at weblogic.jdbc.wrapper.PreparedStatement.setInt(PreparedStatement.java:536)

I am implementating the Paging in jsp. I m using The TYPES.

parameterList.add( new QueryParameter( Types.INTEGER , param.getTipoClass() ) );
parameterList.add( new QueryParameter( Types.VARCHAR , param.getMesiDiReferimento() ) );
parameterList.add( new QueryParameter( Types.VARCHAR , param.getSuccursale() ) );

paramList is an ArrayList:: Dn't Worry Abount That.

My Sql ::    SELECT AC_CODICE_HOST,
AC_SUCCURSALE,
AC_ALARM_ID,
AC_IMPORTO_PERFEZIONATO,
AC_IMPORTO_UTILIZZATO,
AC_SCORING_RATING,
AC_TIPO_CLIENTE,
AC_CODICE_ULTIMO_DELIBANTE,
AC_SCADENZA_INTERVENTO
FROM ALCR_TR_CADR_PRATICHE
WHERE AC_TIPO_CLASS = ?
AND AC_MESE_DI_RIFERIMENTO = last_day(TO_DATE(?, 'MM/YYYY'))
AND AC_SUCCURSALE LIKE '%?%'

in java Codes

public PreparedStatement getPreparedStatement( Connection conn ) throws SQLException {
log4Debug.debug( "<Query> =", this.queryString );
PreparedStatement pstmt = conn.prepareStatement( queryString );
int i = 1;
if(parameters != null){
Iterator queryIterator = parameters.iterator();
log4Debug.debug("Parameter SIze  " , String.valueOf(parameters.size()));
for(; queryIterator.hasNext(); i++){
QueryParameter parameter = (QueryParameter)queryIterator.next();
pstmt.setObject(i, parameter.getValue(), parameter.getType());
}
}
log4Debug.debug("<window slot between ",String.valueOf( slotNumber*100) , " and " , String.valueOf(slotNumber*100-99) ,"/>") ;
log4Debug.debug("index =" ,String.valueOf(i));
pstmt.setInt( i ,  slotNumber * 100 + 1 ); // +1 is for checking whether there is next slot or not
log4Debug.debug("INDEX =" ,String.valueOf(i + 1));
log4Debug.debug("slotNumber  =:" ,String.valueOf( slotNumber));
int j = slotNumber * 100 - 99;
pstmt.setInt( i + 1,    j+1); ------> Here Its Throws The Error (Invalid Column Index)
log4Debug.debug("slotNumber  =:" ,String.valueOf( slotNumber));
return pstmt;
}

I dn't understand Y its coming; Please Help me out. Its Very Urgent

Thanks
Rahul B

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.