I have created a script where I try to fetch data from a database to a jtable and when I click submit I store the data from the row into another database. I try to create a refresh button that stores the data but it isn't working.
I have tried to debug it, but I get an error or nothing happens. I have no clue why it happens when I try to add a row. Right now nothing happens and the row doesn't get added.
public void actionPerformed(ActionEvent arg0) {
String myquery = "SELECT * FROM myTable t WHERE t.trade_no NOT IN (SELECT trade_no FROM newTable)";
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
final Connection con = DriverManager.getConnection(
"url", "user",
"password");
preparedStatement = con.prepareStatement(myquery);
rs = preparedStatement.executeQuery(myquery);
rs.next();
row[0] = rs.getString("Trade_Type").toString();
row[0] = rs.getString("Trade_Type").toString();
row[0] = rs.getString("Value_date").toString();
row[0] = rs.getString("CCY_Sold").toString();
row[0] = rs.getString("Amt_Sold").toString();
row[0] = rs.getString("CCY_Bought").toString();
row[0] = rs.getString("Amt_Bought").toString();
row[0] = rs.getString("Rate").toString();
row[0] = rs.getString("Cparty").toString();
con.commit();
con.close();
model.addRow(row);
} catch (Exception e) {
e.printStackTrace();
}
}