0
出更改默认Colomn名字,我有下面的类:如何ResultSet的数据添加到JTable中使用的JTable
public class customer_master extends javax.swing.JInternalFrame {
Connection con = null;
PreparedStatement ps = null;
ResultSet rs = null;
JFrame parent;
public customer_master(JFrame parent) {
this.parent=parent;
initComponents();
try {
String qry="select customer_code, customer_name, customer_address, customer_created_time from customer";
database.JavaConnect jc= new JavaConnect();
con = jc.ConnectDB();
ps = con.prepareStatement(qry);
rs = ps.executeQuery();
jTable1.setModel(DbUtils.resultSetToTableModel(rs));
con.close();
}
catch(SQLException e)
{
JOptionPane.showMessageDialog(null, e);
}
}
}
它还更改列的名字,但我想添加RS不改变列的名字吗,如果任何人都可以帮忙。提前致谢。
嗨Kapil。请考虑在您的问题中添加更多信息。你包括什么课程,目的是什么?你最终的目标是什么?什么是你看到的输出的例子?您提供的信息越多,其他人就越容易提供帮助。当只有一个班级继续学习是很困难的。 – 2013-02-16 16:11:24
我承认我没有提供完整的信息.....我要求一个简单的解决方案,不会改变默认的jTable列名与数据库表中的元数据.... // ** DbUtils.resultSetToTableModel(rs)** //这个函数是用表元数据取代默认的列名....但我一直在搜索,我发现这里的解决方案.... **** http://stackoverflow.com/questions/9599474/jtable-setting -model-and-preserve-column-formats-width-alignment-etc ****谢谢你的支持。非常感谢你.. – 2013-02-17 00:11:40