[英]jTable and SQL Data retrieve
First post, If I made a mistake please forgive me! 第一篇文章,如果我输入有误,请原谅我!
On my jTable "ID", "Name" values from the database show up but the "balance" doesn't! 在我的jTable的“ ID”上,显示了数据库中的“名称”值,但没有显示“余额”!
What's the reason? 什么原因?
Here's the source code : 这是源代码:
private void formWindowOpened(java.awt.event.WindowEvent evt) {
// TODO add your handling code here:
Tools.setCenter(this);
DAL d = new DAL();
Object[][] Customer = d.select("select * from customer");
String[] column = {"ID", "Name", "Balance"};
jTable1 = new javax.swing.JTable(Customer, column);
jScrollPane1.setViewportView(jTable1);
}
private void jTextField1KeyPressed(java.awt.event.KeyEvent evt) {
// TODO add your handling code here:
if (evt.getKeyCode() == 27) {
this.setVisible(false);
}
}
You are not mentioning the exact code needed!! 您没有提到所需的确切代码! Hope that you have created table with 3 columns.. Try this code
希望您已创建具有3列的表。
ps=con.prepareStatement("select * from customer");
rs=ps.exectuteQuery();
while(rs.next())
{
int row=0;
for(int i=1,i<=rsmd.getColumnCount();i++)
{
jTable1.setValueAt(rs.getString(i),row,i-1);
}
row=row+1;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.