Error in retriving data

Discussions

Web tier: servlets, JSP, Web frameworks: Error in retriving data

  1. Error in retriving data (2 messages)

    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
     
    So please suggest me to remove this error
    Thaks in adv

    Chintan

    Threaded Messages (2)

  2. Error in retriving data[ Go to top ]

    Looks like your are using MS ODBC-JDBC Driver. I remember it has limited capabilities in dealing with database metadata, which is probably what you are trying to retrieve. Try the same code with other database like MySQL
  3. Error in retriving data[ Go to top ]

    checked but it shows no driver found though my setting is ok..i put the connector.jar into tocmat_home/common/lib and put it into classpath

    pelse see the code and let me know

    i have errro in accessing data. I got the tablenames in Vector but things is that actually i have 3 tables but it shows 20 tables on the command prompt(may be prob. is in loop) and second thing is in the jsp page it shows nothing(in jsp page i have used Enumeration to display data)may be becoz of this it happens...in the jsp page it shows the status "opening page bean.jsp"in the status bar and after some time shows "disk cleanup message".

    Here is my code both DbConnection.java and bean.jsp
    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=1;i<=columns;i++)
    vColumns.addElement(metadata.getColumnName(i));
    }
    }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;
    Object rsColumns;
    Vector vColumns = new Vector();
    public String dbURL = "jdbc:odbc:dsn";
    String query = "SELECT CompanyName FROM temp";
    }
    and bean.jsp page

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

    <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>
    <% Enumeration vEnum = columnList.elements();
    while(vEnum.hasMoreElements())%>
    <% out.println(vEnum.nextElement());%>
    <br>
    </body>
    </html>

    please help me to sovle the prob.