public static boolean doesTableExist ( JdbcOperations jdbcOperations , final String table ) { final boolean tableExists = jdbcOperations . execute ( new ConnectionCallback < Boolean > ( ) { @ Override public Boolean doInConnection ( Connection con ) throws SQLException , DataAccessException { final DatabaseMetaData metaData = con . getMetaData ( ) ; final ResultSet tables = metaData . getTables ( null , null , null , new String [ ] { "TABLE" } ) ; while ( tables . next ( ) ) { final String dbTableName = tables . getString ( "TABLE_NAME" ) ; if ( table . equalsIgnoreCase ( dbTableName ) ) { return true ; } } return false ; } } ) ; return tableExists ; }
Check if the specified table exists