Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
prashant shelke
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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.
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Issue resolved by changing

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

to

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