Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Invalid Descriptor index error

843836Jul 16 2003 — edited Jul 16 2003
I am able to get the connection throgh connection bean. i have also one bean to get all tables from the database. for that my bean name is GetAllColumns() but when i run the jsp page it shows me following error

[Microsoft][ODBC Microsoft Access Driver]Invalid descriptor Index. on the command prompt of Tomcat Startup file

here is the .java file and .jsp file plz check it
here I put "##" symbol in .java file where excatly error comes..so plz check it

package development.connection;
import java.beans.*;
import java.sql.*;
import java.util.*;

public class DbConnection {


/** Creates new DbConnection */
public Connection getDbConnection() {
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con = DriverManager.getConnection(dbURL);

}catch(ClassNotFoundException cls){
System.out.println("No Proper Driver Class found for Connection \n");
System.out.println(cls.getMessage());
}catch(SQLException se){
System.out.println("Error creating Connection");
System.out.println(se.getMessage());
}
return con;
}

public void setDbConnection(Connection setcon){
con = setcon;
}


/** get all columns number from the database */
public Vector getAllColumns(){
try{
st = con.createStatement();
rs = st.executeQuery(query);
metadata = rs.getMetaData();
columns = metadata.getColumnCount();

while(rs.next()){
for(int i=0; i<=columns; i++){
## rsColumns = metadata.getColumnName(i+1);

}
vColumns.addElement(rsColumns);

}
}catch(SQLException ex){
System.out.println("\nSQL EXCEPTION(Columns) ------------------\n");
System.out.println(ex.getSQLState());
System.out.println(ex.getMessage());
}
return vColumns;
}
public void setAllColumns(Vector noColumns){
vColumns = noColumns;
}

/** Destroy the connection */
public void destroyConnection(){
if(con != null)
try{
con.close();
con = null;
}catch(SQLException ex){
System.out.println("\nSQL EXCEPTION------------------\n");
System.out.println(ex.getSQLState());
System.out.println(ex.getMessage());
}
}


public Connection con= null;
public Statement st = null;
public ResultSet rs = null;
public ResultSetMetaData metadata;
public int columns;
String[] rsColumns = new String[columns];
Vector vColumns = new Vector();
public String dbURL = "jdbc:odbc:dsn";
String query = "SELECT * FROM customers";
}
here is jsp file

<%@ page import="java.util.Vector" %>

<jsp:useBean id="connectBean"
class="development.connection.DbConnection" scope="session" />
<html>
<head>
<title>JSP BEAN EXAMPLE</title>
</head>
<body>
<jsp:setProperty name="connectBean" property="dbConnection" />
<%= connectBean.getDbConnection() %>
<br>
<jsp:setProperty name="connectBean" property="allColumns" />
<% Vector columnList = connectBean.getAllColumns();%>
<br>
<table>
<tr>
<td><b>Name of Columns</b></td>
<% for(int i=0; i < columnList.size(); i++){
String [] sa = (String [])columnList.elementAt(i);
%>
<tr>
<% for(int j=0; i < sa.length; j++) {%>
<td><b>
<%= sa[j] %>
</b></td>
<%} %>

</tr>
<% } %>
</table>
</body>
</html>

please chek it and let me know what's wrong

Regrds
Chitnan
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 13 2003
Added on Jul 16 2003
13 comments
295 views