public Vector get()throws Exception
{
Vector<Vector<String>> vector = new Vector<Vector<String>>();
Connection conn = dbConnection();
PreparedStatement pre = conn.prepareStatement("select * from tb_azioni order by azcodaz");
ResultSet rs = pre.executeQuery();
while(rs.next())
{
Vector<String> s = new Vector<String>();
s.add(rs.getString(4));
s.add(rs.getString(5));
s.add(rs.getString(6));
s.add(rs.getString(1));
s.add(rs.getString(7));
vector.add(s);
}
/*Close the connection after use (MUST)*/
if(conn!=null)
conn.close();
return vector;
}
private Vector<Vector<String>> data; //used for data from database
private Vector<String> header; //used to store data header
data = get();
JTable table5=new JTable(data,header);
for(int i2=0;i2<table5.getRowCount();i2++){
Object[] d={data.get(i2).get(0),data.get(i2).get(1),data.get(i2).get(2),data.get(i2).get(3),data.get(i2).get(4)};
model.addRow(d);
}
DefaultTableModel model=new DefaultTableModel(data,header);
JTable table=new JTable(model);