Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- try{
- Class.forName("com.mysql.jdbc.Driver");
- cn22= DriverManager.getConnection("jdbc:mysql://localhost:3306/mmtc?zeroDateTimeBehavior=convertToNull", "root", "");
- st22=cn22.createStatement();
- st23=cn22.createStatement();
- st24=cn22.createStatement();
- st25=cn22.createStatement();
- }
- catch(Exception e){
- JOptionPane.showMessageDialog(null, "Not Connected.");
- }
- DateFormat df=new SimpleDateFormat("M/d/yy");
- Date dateobj=new Date();
- String datetoday=df.format(dateobj);
- Date todaydate=datechanger(datetoday);
- DateTime dt1=new DateTime(todaydate);
- String fetchdate="Select nextdate from newentry where location='"+Login.locationofcurrentuser+"'";
- String fetchdatecount="select count(*) as total from newentry where location='"+Login.locationofcurrentuser+"'";
- ResultSet rsdash=st23.executeQuery(fetchdate);
- ResultSet rsdashcount=st24.executeQuery(fetchdatecount);
- String dategetter="Select caseno from newentry where location='"+Login.locationofcurrentuser+"'";
- ResultSet rss786=st25.executeQuery(dategetter);
- if(rsdashcount.next()){
- int size=rsdashcount.getInt("total");
- ArrayList<String> a=new ArrayList<String>();
- ArrayList<String> caseno=new ArrayList<String>();
- while(rss786.next()){
- int y=1;
- while(y<=size){
- caseno.add(rss786.getString(y++));
- }
- }
- ArrayList<Date> dates=new ArrayList<Date>();
- while(rsdash.next()){
- int z=1;
- while(z<=size){
- a.add(rsdash.getString(z++));
- }
- }
- for(int i=0;i<size;i++){
- dates.add(datechanger(a.get(i)));
- DateTime dt2=new DateTime(dates.get(i));
- int gap=Days.daysBetween(dt1,dt2).getDays();
- ArrayList<String> b=new ArrayList<String>();
- if (gap<4){
- b.add("Upcoming case-"+caseno.get(i)+" due on-"+a.get(i)+"");
- System.out.println(b);
- }
- notification.setText(b.toString());
- }
- }else
- {
- notification.setText("No Upcoming Cases.");
- }
- java.sql.SQLException: Column Index out of range, 2 > 1.
- at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
- at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
- at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
- at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
- at com.mysql.jdbc.ResultSetImpl.checkColumnBounds(ResultSetImpl.java:831)
- at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5774)
- at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5693)
- at mmtc.Dashboard.<init>(Dashboard.java:79)
- caseno.add(rss786.getString(y++));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement