wood burning stoves 2.0*
The moose likes JDBC and the fly likes Invalid Descriptor Index 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 "Invalid Descriptor Index" Watch "Invalid Descriptor Index" New topic

Invalid Descriptor Index

David Cavanagh

Joined: May 01, 2006
Posts: 1
Hi i keep on getting this error:
Problem: java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Invalid Descriptor Index
Its really wrecking my head and ive tried everything.Below is a copy of my code.Any suggestions?

import java.io.*;
import java.sql.*;
//import oracle.jdbc.*;

public class dbTest
static Connection conn;
static String username, password;
static Statement stmt= null;

public static void main(String [] args)
conn = null;

//Load the jdbc-odbc bridge driver

username = "ca4photo";
password = "Tmppwd4db";
conn = DriverManager.getConnection("jdbc dbc:images",username,password);
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, //Create a statement object so that we can submit
ResultSet.CONCUR_UPDATABLE); //SQL statements to the driver
//ResultSet rs = null;
String query = "SELECT idx FROM images where idx = 48046"; //SQL statement
ResultSet rs = stmt.executeQuery(query); //Execute SQL statement

String photo = rs.getString(1);
int ccount = rs.getMetaData().getColumnCount();
for( int i = 1; i <= ccount; i++ )

if(conn != null)
catch(Exception e)
System.out.println("Could'nt close connection \n"+e);
catch(Exception e)
System.out.println("Problem: "+e);

public Connection getConnection()
return conn;

Maximilian Xavier Stocker
Ranch Hand

Joined: Sep 20, 2005
Posts: 381
You are trying to access columns of your result set that don't exist. That's what that error actually means.

I am not sure about your looping through the metadata part but this

Is certainly wrong. You only have one column in your result set.
It is sorta covered in the JavaRanch Style Guide.
subject: Invalid Descriptor Index
Similar Threads
Hi,I have a problem in database connection
Failed to load JDBC/ODBC driver.
DataSource issues
jsf and database connection problem
accessdata using excel