Vote count:
0
I have a form which contains a Jtable which should fill up data from a database, even though my code seems correct and the calculations are done, the GUI form does not open, screen stays at output section. My code:
public void inventory() throws SQLException
{
Connection con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","IND","password");
Statement stmt = null;
ResultSet rs = null;
//SQL query command
stmt = con.createStatement();
int i = 0;
String SQL1 = "select * from final_inv";
rs = stmt.executeQuery(SQL1);
for (i=0;i<10;){
while(rs.next())
{
Object category = rs.getString("Category");
Object Item = rs.getString("Item");
Object Avg = rs.getString("Avg_Price");
Object qty = rs.getString("QTY");
jTable1.getModel().setValueAt(category,i,0);
jTable1.getModel().setValueAt(Item, i,1);
jTable1.getModel().setValueAt(qty, i, 2);
jTable1.getModel().setValueAt(Avg, i, 3);
i++;
}
}
}
public void delete() throws SQLException
{
Connection con;
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","IND","passoword");
//SQL query command
String SQL = "delete from final_inv";
PreparedStatement pstmt = con.prepareStatement(SQL);
pstmt.executeUpdate();
}
public void refresh() throws SQLException
{
Connection con;
con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","IND","apnair9902");
//SQL query command
String SQL = "insert into final_inv (CATEGORY, ITEM, Avg_Price, QTY) select inv.CATEGORY, inv.ITEM, sum(Inv.tot_Price) / sum(Inv.qty) as Avg_Price, sum(inv.QTY) - NVL((select SUM(INV_ISS.QTY) from INV_ISS where inv.CATEGORY = inv_iss.CATEGORY and inv.ITEM = inv_iss.ITEM),0) as QTY from inv group by inv.CATEGORY, inv.ITEM";
PreparedStatement pstmt = con.prepareStatement(SQL);
pstmt.executeUpdate();
System.out.println("Succesfully Updated");
}
private void formMouseClicked(java.awt.event.MouseEvent evt) {
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
try {
delete();
} catch (SQLException ex) {
Logger.getLogger(Inventory.class.getName()).log(Level.SEVERE, null, ex);
}
try {
refresh();
} catch (SQLException ex) {
Logger.getLogger(Inventory.class.getName()).log(Level.SEVERE, null, ex);
}
try {
inventory();
} catch (SQLException ex) {
Logger.getLogger(Inventory.class.getName()).log(Level.SEVERE, null, ex);
}
}
When i run this, no window is opened only calculations are done in the output section and the program keeps running with no further result
P.S sry for the long code
asked 1 min ago
GUI Form does not open (Jtable)
Aucun commentaire:
Enregistrer un commentaire