java swing怎样将数据库取出的内容填到JTable里?
数据库的数据取出来了,但是要怎样才能让它填到如图定义好的JTable表格里面去呢?代码如下:classStuShowGUIextendsJPanelimplementsA...
数据库的数据取出来了,但是要怎样才能让它填到如图定义好的JTable表格里面去呢? 代码如下:class StuShowGUI extends JPanel implements ActionListener{ JTable stuTable; JScrollPane sp; JButton quit; Object[][]stuInfo =new Object[40][4]; final Object[] colName ={"编号","书名","类型","状态"}; public StuShowGUI(){ try{ stuTable =new JTable(stuInfo,colName); sp =new JScrollPane(stuTable); String sql="select * from bookdir"; ResultSet rs=DAO.executeQuery(sql); while(rs.next()){ String Bno = rs.getString(1); String Bname = rs.getString(2); String Bkind = rs.getString(3); String Bcondtion = rs.getString(4); } } catch (Exception e) { e.printStackTrace(); }
展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询