Search code examples
javamysqlswingawtresultset

Display tables of a database in java


I'm working on a java application, and I want to display the list of the tables in a Mysql database, I searched on the net and I found that "SHOW TABLES FROM [DB]" is the appropriate request, but how can I dispaly the result of this last on a java swing/awt application, PS : I tried to put the result of the request on a resultset,

res = sta.executeQuery("SHOW TABLES FROM sinpec ");

but it doesnt work ...

How can I proceed ?


Solution

  • Please try this query:-

    SELECT TABLE_NAME 
    FROM INFORMATION_SCHEMA.TABLES 
    WHERE table_schema = "DATABASE_NAME"