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;
}
}
jahanruhi3@gmai
0
Newbie Poster
Recommended Answers
Jump to Postnice 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 …
All 3 Replies
stultuske
1,116
Posting Maven
Featured Poster
jahanruhi3@gmai
0
Newbie Poster
stultuske
1,116
Posting Maven
Featured Poster
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.