• Post Reply Bookmark Topic Watch Topic
  • New Topic

problem of updating  RSS feed

 
bijoy bose
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class itemList implements ActionListener
{
public void actionPerformed (ActionEvent ie)
{
String lst;
lst=ie.getActionCommand();
if(lst.equals("Individual"))
{
J5.setEnabled(true);
f1.setEnabled(true);
btnDetail.setEnabled(true);
}
if( lst.equals("Entire Group"))
{
J5.setEnabled(false);
f1.setEnabled(false);
btnDetail.setEnabled(false);
}
if(lst.equals("Exit"))
{
setVisible(true); //window closing
dispose();
}

// PHASE II OF THE PROJECT STARTS HERE
// gets the drugs names from the lists which are selected and to be analysed
if(lst.equals("Corrects Dates"))
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(java.lang.ClassNotFoundException e)
{
System.err.print("ClassNotFoundException: ");
System.err.println(e.getMessage());
}
int selA = listA.getSelectedIndex();
Object selB[] = listB.getSelectedValues();
Iterator itr = confounderB.iterator();
if(selA != -1)
{
confounderA = (String)listA.getModel().getElementAt(selA);
//System.out.println("the selected item in ListA is: "+confounderA);
}
else
{
// display error message
System.out.println("ERROR");
}
while(itr.hasNext())
confounderB.remove(0);
for(int i =0; i <selB.length; i++)
{
confounderB.add(i,selB[i]);
}
for (int i=0; i<selB.length;i++)
{
String var = (String) confounderB.get(i); //BIG TEST SUCCESS
//System.out.println("the selected item in ListB is: "+var);
//System.out.println("the selected item in ListB is: "+confounderB.get(i));
}
try
{
con = DriverManager.getConnection(url, "", "");
//con1 = DriverManager.getConnection(url, "", "");
stmt = con.createStatement();
stmtA = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
ResultSet.CONCUR_UPDATABLE);
//stmtB = con1.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,
//ResultSet.CONCUR_UPDATABLE);
//HAVE TO WORK HERE (currently working)
//Correcting Dates FOR A
try
{
String Osdate = f4.getText();
df = DateFormat.getDateInstance(DateFormat.SHORT);
Ostudy_end = (Date)df.parse(Osdate);
}
catch(ParseException e)
{
System.out.println("Error in date parsing");
}
boolean brake = false;
queryx ="Select * From cleanTableA order by START_DATE";
ResultSet rsAcd = stmtA.executeQuery(queryx);
while(rsAcd.next())
{
Date TmpStudyEnd = Ostudy_end;
String parseDrugnm = rsAcd.getString(4);
int index = parseDrugnm.indexOf(" ");
String result = parseDrugnm.substring(0,index);
if(!confounderA.equals(result))
{
rsAcd.deleteRow();
rsAcd.previous();
}
else
{
Date DOD = rsAcd.getDate(5);
String dod = df.format(DOD);
if(!dod.equals(""))
{
if( DOD.before(TmpStudyEnd))
TmpStudyEnd = DOD;
}
Date StartD = rsAcd.getDate(2);
if (StartD.after(TmpStudyEnd))
{
rsAcd.deleteRow();
rsAcd.previous();
}
else
{
//rowset
Date EndD = rsAcd.getDate(3);

if(EndD.after(TmpStudyEnd))
{
System.out.println("the current end date is: "+TmpStudyEnd);
EndD = TmpStudyEnd;
System.out.println("the current end date is: "+EndD);
df2 = DateFormat.getDateInstance(DateFormat.SHORT);
String tmpend = df2.format(EndD);
System.out.println("the current end date is: "+tmpend);
rsAcd.updateLong(3, java.sql.Date.parse(tmpend));

}

}

}

// System.out.println(parseDrugnm);
}
stmtA.close();
//stmtB.close();
con.close();
//con1.close();
//rsAcd.close();

}
catch(SQLException ex)
{
System.err.println("SQLException: " + ex.getMessage());
}

} // end of correct dates button

} // end of action performed

} // end of itemList class


the problem is it is not updating in the actuall Table (cleanTableA)


Can Anyone Help.....Please


 
bijoy bose
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry!
the main problem lies here!
rsAcd.updateLong(3, java.sql.Date.parse(tmpend));
 
bijoy bose
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is this, something to do with connection.....i mean is it that i have to add something in the connection line to make itauto updatable and commit automatically ???

please help....i am really stuck'

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!