Advertisement
Guest User

Untitled

a guest
Aug 7th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.72 KB | None | 0 0
  1. try{
  2. Class.forName("com.mysql.jdbc.Driver");
  3. cn22= DriverManager.getConnection("jdbc:mysql://localhost:3306/mmtc?zeroDateTimeBehavior=convertToNull", "root", "");
  4. st22=cn22.createStatement();
  5. st23=cn22.createStatement();
  6. st24=cn22.createStatement();
  7. st25=cn22.createStatement();
  8.  
  9.  
  10. }
  11. catch(Exception e){
  12. JOptionPane.showMessageDialog(null, "Not Connected.");
  13.  
  14. }
  15. DateFormat df=new SimpleDateFormat("M/d/yy");
  16. Date dateobj=new Date();
  17. String datetoday=df.format(dateobj);
  18.  
  19. Date todaydate=datechanger(datetoday);
  20. DateTime dt1=new DateTime(todaydate);
  21. String fetchdate="Select nextdate from newentry where location='"+Login.locationofcurrentuser+"'";
  22. String fetchdatecount="select count(*) as total from newentry where location='"+Login.locationofcurrentuser+"'";
  23. ResultSet rsdash=st23.executeQuery(fetchdate);
  24. ResultSet rsdashcount=st24.executeQuery(fetchdatecount);
  25. String dategetter="Select caseno from newentry where location='"+Login.locationofcurrentuser+"'";
  26. ResultSet rss786=st25.executeQuery(dategetter);
  27.  
  28. if(rsdashcount.next()){
  29.  
  30. int size=rsdashcount.getInt("total");
  31.  
  32.  
  33. ArrayList<String> a=new ArrayList<String>();
  34. ArrayList<String> caseno=new ArrayList<String>();
  35. while(rss786.next()){
  36. int y=1;
  37. while(y<=size){
  38. caseno.add(rss786.getString(y++));
  39.  
  40. }
  41. }
  42.  
  43.  
  44. ArrayList<Date> dates=new ArrayList<Date>();
  45. while(rsdash.next()){
  46. int z=1;
  47. while(z<=size){
  48. a.add(rsdash.getString(z++));
  49. }
  50. }
  51.  
  52.  
  53. for(int i=0;i<size;i++){
  54. dates.add(datechanger(a.get(i)));
  55.  
  56.  
  57.  
  58. DateTime dt2=new DateTime(dates.get(i));
  59. int gap=Days.daysBetween(dt1,dt2).getDays();
  60. ArrayList<String> b=new ArrayList<String>();
  61.  
  62. if (gap<4){
  63.  
  64.  
  65.  
  66. b.add("Upcoming case-"+caseno.get(i)+" due on-"+a.get(i)+"");
  67. System.out.println(b);
  68.  
  69.  
  70.  
  71.  
  72.  
  73.  
  74.  
  75.  
  76. }
  77. notification.setText(b.toString());
  78.  
  79.  
  80. }
  81.  
  82.  
  83. }else
  84. {
  85. notification.setText("No Upcoming Cases.");
  86. }
  87.  
  88. java.sql.SQLException: Column Index out of range, 2 > 1.
  89. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1074)
  90. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:988)
  91. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:974)
  92. at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:919)
  93. at com.mysql.jdbc.ResultSetImpl.checkColumnBounds(ResultSetImpl.java:831)
  94. at com.mysql.jdbc.ResultSetImpl.getStringInternal(ResultSetImpl.java:5774)
  95. at com.mysql.jdbc.ResultSetImpl.getString(ResultSetImpl.java:5693)
  96. at mmtc.Dashboard.<init>(Dashboard.java:79)
  97.  
  98. caseno.add(rss786.getString(y++));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement