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 * from project_stage");
                {
                    ArrayList aL1 = new ArrayList();
                    while(rs1.next()){
                        aL1.add(rs1.getString(5));
                    }aL.addAll(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;

    }
}

Recommended Answers

All 3 Replies

nice code.
1. add code tags
2. do understand you did not provide us of a schedule of your DB, which is where your problem lies.

an invalid column index is something what may occur if you ask for the contents of the fourth column, if your table only has three columns.

CREATE TABLE PROJECT_STAGE(IK int NOT NULL UNIQUE,
P6_TRANSACTION_TYPE nvarchar2(2) NULL,
ObjectID int NOT NULL,
Id nvarchar2(40) NULL,
Name nvarchar2(120) NULL,
StartDate TIMESTAMP NULL,
FinishDate TIMESTAMP NULL,
SCHED_ITEM_ID int NULL,
CREATE_DATE TIMESTAMP NULL,
LAST_UPDATE_DATE TIMESTAMP NULL,
ACTIVE int NULL,PRIMARY KEY(Id));

CREATE TABLE SCHEDULE(IK int NOT NULL PRIMARY KEY,
DESCRIPTION nvarchar2(200) NULL,
RUN_DATE TIMESTAMP NULL,
TYPE_TASKS_FK varchar2(50) NOT NULL,
RUNNING int NULL,
USER_SCHEDULED int NULL,
CONSTRAINT tblSchAct_fk FOREIGN KEY (IK,TYPE_TASKS_FK) REFERENCES TASKS1(IK,TYPE_TASKS));

mm ... I think you're not always reading your data into the correct datatype, maybe that's the problem.

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.