Connection conn = null;
ResultSet rs = null;
PreparedStatement pst = null;
public UserInfo() {
initComponents();
conn = ConnectSQL.getConnection();//import class construtor connect sql
loadData();
}
private void loadData(){
try{
String sql = "select * from userinfo ";
pst= conn.prepareStatement(sql);
rs= pst.executeQuery();
tbl_userinfo.setModel(DbUtils.resultSetToTableMode l(rs));
}catch(Exception e){
JOptionPane.showMessageDialog(this, e);
}finally{
try {
rs.close();
pst.close();
} catch (Exception e) {
}
}
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
String sql =" select min(presure),max(presure),avg(presure) from userinfo ";
pst = conn.prepareStatement(sql);
rs = pst.executeQuery();
String min = rs.getString("min(presure)");
txtMin.setText(min);
String max = rs.getString("max(presure)");
txtMin.setText(max);
String avg = rs.getString("avg(presure)");
txtMin.setText(avg);
} catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
tab pen.jpg