i want to get a list of databases stored in mysql and put in java table using command "show databases" via a resultset. but its not working.
DefaultTableModel model=(DefaultTableModel)dbTbl.getModel();
try{
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql//localhost/:3306","root","password");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("show databases;");
while(rs.next())
{
String db=rs.getString(1);
model.addRow(new Object[] {db});
}
rs.close();
stmt.close();
con.close();
}
catch(Exception e)
{
JOptionPane.showMessageDialog(null,"nahi chalda");
}