I am creating simple Inventory java Application so I what to display customer completer order and payment from MySQL tables in java. I wanted to display the customer ledger in java Jtables. I am unable to display the table in required from it is display only in one row . but i want the data in two row. Below images are the both MySql tables :
[
http://i.stack.imgur.com/6AIwv.jpg[
]]
and this below image is the required format :
http://i.stack.imgur.com/tm7IJ.png[
][
]
please any one help me....
What I have tried:
The java code i have tried is below
private void Table_display(){
try{
st = conn.createStatement();
rst = st.executeQuery("select a.Ref_ID,b.PayRefID,a.Date as OrderDate,b.Date as PaymentDate,a.Narration,b.Bank_Details,a.Vehicle_No,a.Quantity,a.Price,(a.Quantity * a.Price) as Amount from purchase a left join payment b on a.Ref_ID = b.Ref_Id");
ResultSetMetaData rsmd = rst.getMetaData();
int colcount = rsmd.getColumnCount();
Vector column = new Vector(colcount);
for(int i = 1; i <= colcount; i++)
column.add(rsmd.getColumnName(i));
Vector data = new Vector();
Vector row;
while(rst.next()){
row = new Vector(colcount);
for(int i=1; i <= colcount; i++){
row.add(rst.getString(i));
}
data.add(row);
}
DefaultTableModel model = new DefaultTableModel(data, column);
jAccount_table.setModel(model);
}catch(SQLException e){
JOptionPane.showMessageDialog(null, e);
}
}