how to set all available tables in a database to a text field
Please,I am working on an application where I need to select a table from
the database i.e, the tables must be available all the time on that panel
of selection. I created a method to show all available tables on a
database and the method is present in my constructor. Now,only one of the
tables is showing where required and i tried to set the tables to
jTextFieds but still, one of the tables is showing. Please how do i
resolve this to show all available tables to designated textfields and
from there and i shall work on setting them to a jCombobox. Bellow is my
snippet:
public void combo(){
try {
String sql="SHOW TABLES FROM cctdba";
//SQL for selecting the table cctdba Database
pst = conn.prepareStatement(sql);
rs=pst.executeQuery(sql);
while (rs.next()) {
jTextField1.setText(rs.getString(1));
jTextField2.setText(rs.getString(2));
//Displaying the first two tables into the
textfield(Unresloved)
}
// TODO add your handling code here:
}
catch(Exception e){
}
}
Please I need help. Thanks
No comments:
Post a Comment