Here you can find the source of getAllTableNames(Connection connection)
Parameter | Description |
---|---|
connection | connection |
Parameter | Description |
---|
public static List<String> getAllTableNames(Connection connection) throws SQLException
//package com.java2s; import java.sql.Connection; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; public class Main { /**/*w w w.j av a2 s.c om*/ * Returns a list of all table names in the database schema accessible by * the given connection. * * @param connection connection * @return list of table names * @throws java.sql.SQLException if connection fails or meta-data could not be retrieved */ public static List<String> getAllTableNames(Connection connection) throws SQLException { List<String> tables = new ArrayList<String>(); ResultSet rs = connection.getMetaData().getTables(null, null, null, null); while (rs.next()) tables.add(rs.getString(3)); rs.close(); return tables; } }