I'm trying to get selection from J combo Box and use that to find table from the data base. But instead an error comes up:
My codes it:
JButton btnGo = new JButton("Go!");
btnGo.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
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 x = comboBox.getSelectedItem().toString();
String sql="select * from " + x;
pst=conni.prepareStatement(sql);
rs=pst.executeQuery();
while(rs.next()){
String name = rs.getString("Namet");
nameofguy.setText(rs.getString(name));
}
}catch(Exception i){
JOptionPane.showMessageDialog(null, i);
}
I'm searching for table.. but it says cannot find column.
Aucun commentaire:
Enregistrer un commentaire