• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

MSSQL throwing "java.lang.ArrayIndexOutOfBoundsException: 20" for getColumn()

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am facing confusing exception as :

java.lang.ArrayIndexOutOfBoundsException: 20
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.getColumn(SQLServerResultSet.java:508)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.skipColumns(SQLServerResultSet.java:134)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.discardCurrentRow(SQLServerResultSet.java:1472)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.fetchBufferNext(SQLServerResultSet.java:1525)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.discardFetchBuffer(SQLServerResultSet.java:4090)
at com.microsoft.sqlserver.jdbc.SQLServerResultSet.close(SQLServerResultSet.java:410)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.clearLastResult(SQLServerStatement.java:1053)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.getNextResult(SQLServerStatement.java:1359)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.processResults(SQLServerStatement.java:996)
at com.microsoft.sqlserver.jdbc.SQLServerCallableStatement.processBatch(SQLServerCallableStatement.java:133)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.processResponse(SQLServerStatement.java:981)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.resetForReexecute(SQLServerStatement.java:740)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement(SQLServerPreparedStatement.java:334)

at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute(SQLServerPreparedStatement.java:322)
at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:4003)
at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:1550)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:160)
at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:133)
at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeQueryInternal(SQLServerPreparedStatement.java:278)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getResultSetFromStoredProc(SQLServerDatabaseMetaData.java:267)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getResultSetWithProvidedColumnNames(SQLServerDatabaseMetaData.ja
va:283)
at com.microsoft.sqlserver.jdbc.SQLServerDatabaseMetaData.getColumns(SQLServerDatabaseMetaData.java:547)


MSSQL configuration as follows:

Microsoft SQL Server Management Studio Express 9.00.4035.00
Microsoft Data Access Components (MDAC) 6.0.6002.18005 (lh_sp2rtm.090410-1830)
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 8.0.6001.18904
Microsoft .NET Framework 2.0.50727.4200
Operating System 6.0.6002

I am using sqljdbc4.jar

Please help if anybody fix this.
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How many columns does the ResultSet have?

Instead of using the various ResultSet.getXYZ(int) methods, you should be using ResultSet.getXYZ(String).
 
prashant shelke
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.

There are 15 columns per table and loop is on 2000 tables.
I am calling getColumns(database name, null, table name, "%") this method to fetch each table's column list.

One more thing I would like to add is, this method works well for less number of iterations

Note: getColumns() method I am calling on databaseMetaData object which I retrieved from MSSQL connection object.
 
prashant shelke
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Issue resolved by changing

getColumns(database name, null, table name, "%")

to

getColumns(database name, null, table name, null)
reply
    Bookmark Topic Watch Topic
  • New Topic