InterviewSolution
Saved Bookmarks
| 1. |
How Do I Check What Table Types Exist In A Database? |
|
Answer» USE the getTableTypes method of interface java.sql.DatabaseMetaData to PROBE the database for table types. The exact usage is described in the CODE below. public static void main(String[] ARGS) throws Exception{ // Load the database driver - in this case, we // use the Jdbc/Odbc bridge driver. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // Open a connection to the database Connection conn = DriverManager.getConnection("[jdbcURL]", "[login]", "[passwd]"); // Get DatabaseMetaData DatabaseMetaData dbmd = conn.getMetaData(); // Get all table types. ResultSet rs = dbmd.getTableTypes(); // Printout table data while(rs.next()) { // Printout System.out.println("TYPE: " + rs.getString(1)); } // Close database resources rs.close(); conn.close(); } Use the getTableTypes method of interface java.sql.DatabaseMetaData to probe the database for table types. The exact usage is described in the code below. |
|