Here you can find the source of tableIsAccesable(Connection conn, String TableName)
protected static boolean tableIsAccesable(Connection conn, String TableName) throws SQLException
//package com.java2s; //License from project: Apache License import java.sql.*; public class Main { public static int SELECT_PRIVILEGE = 1; public static int INSERT_PRIVILEGE = 2; protected static boolean tableIsAccesable(Connection conn, String TableName) throws SQLException { int NeedsPrivilege = SELECT_PRIVILEGE | INSERT_PRIVILEGE; DatabaseMetaData md = conn.getMetaData(); try {//from w w w .ja va 2 s.co m String me = md.getUserName(); ResultSet rs = md.getTablePrivileges(null, null, TableName); boolean HasResults = false; while (rs.next()) { HasResults = true; String Grantee = rs.getString(5); // gte the table String Privilege = rs.getString(6); // gte the table if (Privilege.equalsIgnoreCase("public")) NeedsPrivilege = 0; if (Privilege.equalsIgnoreCase("insert")) NeedsPrivilege &= ~INSERT_PRIVILEGE; if (Privilege.equalsIgnoreCase("select")) NeedsPrivilege &= ~SELECT_PRIVILEGE; } if (NeedsPrivilege == 0) return (true); return (!HasResults); // so if no results then is OK I guess } catch (SQLException ex) { return (true); // no way to tell } } }