如何从mysql“order table”显示客户分类帐&安培; “支付表”在java中 [英] How to display customer ledger from mysql "order table" & "payment table" in java

查看:100
本文介绍了如何从mysql“order table”显示客户分类帐&安培; “支付表”在java中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建简单的库存Java应用程序,所以我在java中显示客户完成订单和来自MySQL表的付款。我想在java Jtables中显示客户分类帐。我无法显示所需的表格,因为它只显示在一行中。但我想把数据分成两排。下图是两个MySql表:



[ http://i.stack.imgur.com/6AIwv.jpg [ ]]



和下图为所需格式:



http://i.stack.imgur.com/tm7IJ.png [ ] [ ]





请任何人帮助我....



我尝试过:



我试过的java代码如下



private void Table_display(){



尝试{

st = conn.createStatement();

rst = st.executeQuery(select a.Ref_ID,b.PayRefID,a。日期为OrderDate,b。日期为付款mentDate,a.Narration,b.Bank_Details,a.Vehicle_No,a.Quantity,a.Price,(a.Quantity * a.Price)as a amount in purchase a left join a 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;我< = colcount; i ++)

column.add(rsmd.getColumnName(i));



矢量数据= new Vector();

矢量行;



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);

}

}

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);
}
}

推荐答案

看起来你正在使用某种形式的数据绑定来显示细节,这将导致你看到的表格。要创建备用版本,您需要执行以下两项操作之一:

1.手动读取所有数据并将每个项目插入所需的行和列。

2将数据库中的每一行转换为两行,数据分为第一组和最后一列。
It looks like you are using some form of data binding to display the details, which will result in the table you see. To create the alternate version you will need to do one of two things:
1. Read all data manually and insert each item into the row and column you want.
2. Convert each row from the database into two rows with the data split into the first set and last set of columns.


这篇关于如何从mysql“order table”显示客户分类帐&安培; “支付表”在java中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆