package com.batch;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import DBConnection.DBConnect;
public class Batch {
    @SuppressWarnings({ "unchecked", "rawtypes" })
    public ArrayList BatchAction(String ik) {
        Connection conn = null;
        Statement st = null;
        ResultSet rs;
        ResultSet rs1;
        ArrayList al = new ArrayList();
        conn = DBConnect.getConnection();
        final SimpleDateFormat monthDayYearformatter = new SimpleDateFormat(
                "dd MM yyyy HH:mm:ss");
        System.out.print("is it really working....");
        try {
            st = conn.createStatement();
            rs=st.executeQuery("select * from batch order by start_date DESC");
            System.out.println("select * from batch order by start_date DESC");
            while (rs.next()) {
                ArrayList<String> aL = new ArrayList<String>();
                aL.add(Integer.toString(rs.getInt(1)));
                rs1=st.executeQuery("select name from project_stage");
                {
                    ArrayList<String> aL1 = new ArrayList<String>();
                    while(rs1.next()){
                        aL1.add(rs1.getString(5));
                    }al.add(aL1);
                }

                aL.add(Integer.toString(rs.getInt(2)));
                java.util.Date d = rs.getTimestamp(3);
                if (d != null) {
                    String date = monthDayYearformatter.format(d);
                    aL.add(date);
                }
                else{
                    aL.add("No Start Date Found ");
                }
                java.util.Date d1 = rs.getTimestamp(4);
                if (d1 != null) {
                    String date1 = monthDayYearformatter.format(d1);
                    aL.add(date1);
                }
                else{
                    aL.add("No End Date Found");
                }
                String stageType = rs.getString(5);
                if(stageType != null)

                {
                    aL.add(stageType);
                }
                else
                {

                aL.add("No Stage Type Data Found ");
                }
                aL.add(Integer.toString(rs.getInt(6)));
                al.add(aL);
            }

            conn.setAutoCommit(true);

        } catch (SQLException e) {
            e.printStackTrace();
        }
        return al;

    }
}

Error

14:53:49,424 ERROR [STDERR] java.sql.SQLException: Invalid column index
14:53:49,424 ERROR [STDERR]     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
14:53:49,424 ERROR [STDERR]     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
14:53:49,424 ERROR [STDERR]     at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:208)
14:53:49,424 ERROR [STDERR]     at oracle.jdbc.driver.OracleResultSetImpl.getString(OracleResultSetImpl.java:379)
14:53:49,424 ERROR [STDERR]     at com.batch.Batch.BatchAction(Batch.java:29)

The javadoc states that only one ResultSet object per Statement object can be open at the same time. Therefore, if the reading of one ResultSet object is interleaved with the reading of another, each must have been generated by different Statement objects. Also you should close the statement object when you are done with the query, using the finally block would be good way to do that saves resources.

check out the javadoc
http://docs.oracle.com/javase/6/docs/api/java/sql/Statement.html

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.