I was just trying to call data from the database when I press a button. Here's my code
JButton btnRefresh = new JButton("Refresh");
btnRefresh.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
Connection conni = null;
ResultSet rs=null;
PreparedStatement pst=null;
try{
Class.forName("org.sqlite.JDBC");
conni = DriverManager.getConnection("jdbc:sqlite://C://Users//Asus//Dropbox//TireShop.sqlite");
String sql="select * from Namet";
pst=conni.prepareStatement(sql);
rs=pst.executeQuery();
while(rs.next()){
String name = rs.getString("Namet");
comboBox.addItem(name);
}
}catch(Exception i){
JOptionPane.showMessageDialog(null, e);
}
Then this thing keeps coming when I press refresh.
Aucun commentaire:
Enregistrer un commentaire