I have created a program to fetch all the table names from the user rt using DatabaseMetaData
, although the program is compiled successfully and running it is not fetching the table names. It runs and displays list of tables: and then no names. Program exits.
Could anyone here please help me to find the wrong logic in my program.
//DataBaseMetaDataTest
import java.sql.*;
class DatabaseMetaDataTest
{
public static void main(String s[])
{
try
{
Connection con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","rt","pwdd");
DatabaseMetaData dbmd=con.getMetaData();
ResultSet rs=dbmd.getTables(null,"rt",null,new String[]{"Table"});
System.out.println("list of tables:");
while(rs.next())
{
System.out.println(rs.getString(3));
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
}