This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes MSSQL throwing Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "MSSQL throwing "java.lang.ArrayIndexOutOfBoundsException: 20" for getColumn()" Watch "MSSQL throwing "java.lang.ArrayIndexOutOfBoundsException: 20" for getColumn()" New topic
Author

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

prashant shelke
Greenhorn

Joined: Mar 10, 2009
Posts: 14
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

Joined: Oct 14, 2008
Posts: 1337
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

Joined: Mar 10, 2009
Posts: 14
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

Joined: Mar 10, 2009
Posts: 14
Issue resolved by changing

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

to

getColumns(database name, null, table name, null)
 
Consider Paul's rocket mass heater.
 
subject: MSSQL throwing "java.lang.ArrayIndexOutOfBoundsException: 20" for getColumn()
 
Similar Threads
Bilingual JSP application
jboss to b configured with mssql
java.lang.ArrayIndexOutOfBoundsException: 1 >= 0
NullPointer exception for MSSQL database (SQLServerDatabaseMetaData.java:287)
how to use MSSQL for JMS