Code example for DatabaseMetaData

Methods: getTables

0
      System.err.println("Checking if table " + tableName + " exists...");
    } 
    DatabaseMetaData dbmd = m_Connection.getMetaData();
    ResultSet rs;
    if (m_checkForUpperCaseNames) {
      rs = dbmd.getTables (null, null, tableName.toUpperCase(), null);
    } else if (m_checkForLowerCaseNames) {
      rs = dbmd.getTables (null, null, tableName.toLowerCase(), null);
    } else { 
      rs = dbmd.getTables (null, null, tableName, null);
    } 
    boolean tableExists = rs.next();
    if (rs.next()) {
      throw new Exception("This table seems to exist more than once!");
    } 
    rs.close();
    if (m_Debug) {
      if (tableExists) {
	System.err.println("... " + tableName + " exists");
      } else { 
	System.err.println("... " + tableName + " does not exist");