Java examples for JDBC:Table
check View Exists
//package com.java2s; import java.sql.Connection; import java.sql.DatabaseMetaData; import java.sql.ResultSet; import java.sql.SQLException; public class Main { public static boolean checkViewExists(Connection conn, String tableName) { try {//from ww w.j a v a 2 s .co m DatabaseMetaData meta = conn.getMetaData(); ResultSet rset = meta.getTables(null, null, null, new String[] { "VIEW" }); while (rset.next()) { if (rset.getString("TABLE_NAME") .equalsIgnoreCase(tableName)) { return true; } } } catch (SQLException ex) { throw new RuntimeException(ex.getMessage(), ex); } return false; } }