/** * Return true if table tableName contains field fieldName. * * @param connection Connection * @param tableName Table name * @param fieldName Field name * @return True if the table contains the field * @throws SQLException */ public static boolean hasField(Connection connection, String tableName, String fieldName) throws SQLException { final Statement statement = connection.createStatement(); try { final ResultSet resultSet = statement.executeQuery( "SELECT * FROM " + TableLocation.parse(tableName) + " LIMIT 0;"); try { return hasField(resultSet.getMetaData(), fieldName); } finally { resultSet.close(); } } catch (SQLException ex) { return false; } finally { statement.close(); } }
/** * Return true if table tableName contains field fieldName. * * @param connection Connection * @param tableName Table name * @param fieldName Field name * @return True if the table contains the field * @throws SQLException */ public static boolean hasField(Connection connection, String tableName, String fieldName) throws SQLException { final Statement statement = connection.createStatement(); try { final ResultSet resultSet = statement.executeQuery( "SELECT * FROM " + TableLocation.parse(tableName) + " LIMIT 0;"); try { return hasField(resultSet.getMetaData(), fieldName); } finally { resultSet.close(); } } catch (SQLException ex) { return false; } finally { statement.close(); } }
/** * Return true if table tableName contains field fieldName. * * @param connection Connection * @param tableName Table name * @param fieldName Field name * @return True if the table contains the field * @throws SQLException */ public static boolean hasField(Connection connection, String tableName, String fieldName) throws SQLException { final Statement statement = connection.createStatement(); try { final ResultSet resultSet = statement.executeQuery( "SELECT * FROM " + TableLocation.parse(tableName) + " LIMIT 0;"); try { return hasField(resultSet.getMetaData(), fieldName); } finally { resultSet.close(); } } catch (SQLException ex) { return false; } finally { statement.close(); } }
/** * Read INFORMATION_SCHEMA.TABLES in order to see if the provided table reference is a temporary table. * @param connection Active connection not closed by this method * @param tableReference Table reference * @return True if the provided table is temporary. * @throws SQLException If the table does not exists. */ public static boolean isTemporaryTable(Connection connection, String tableReference) throws SQLException { TableLocation location = TableLocation.parse(tableReference); ResultSet rs = getTablesView(connection, location.getCatalog(), location.getSchema(), location.getTable()); boolean isTemporary = false; try { if(rs.next()) { String tableType; if(hasField(rs.getMetaData(), "STORAGE_TYPE")) { // H2 tableType = rs.getString("STORAGE_TYPE"); } else { // Standard SQL tableType = rs.getString("TABLE_TYPE"); } isTemporary = tableType.contains("TEMPORARY"); } else { throw new SQLException("The table "+location+" does not exists"); } } finally { rs.close(); } return isTemporary; }
/** * Read INFORMATION_SCHEMA.TABLES in order to see if the provided table reference is a temporary table. * @param connection Active connection not closed by this method * @param tableReference Table reference * @return True if the provided table is temporary. * @throws SQLException If the table does not exists. */ public static boolean isTemporaryTable(Connection connection, String tableReference) throws SQLException { TableLocation location = TableLocation.parse(tableReference); ResultSet rs = getTablesView(connection, location.getCatalog(), location.getSchema(), location.getTable()); boolean isTemporary = false; try { if(rs.next()) { String tableType; if(hasField(rs.getMetaData(), "STORAGE_TYPE")) { // H2 tableType = rs.getString("STORAGE_TYPE"); } else { // Standard SQL tableType = rs.getString("TABLE_TYPE"); } isTemporary = tableType.contains("TEMPORARY"); } else { throw new SQLException("The table "+location+" does not exists"); } } finally { rs.close(); } return isTemporary; }
/** * Read INFORMATION_SCHEMA.TABLES in order to see if the provided table reference is a temporary table. * @param connection Active connection not closed by this method * @param tableReference Table reference * @return True if the provided table is temporary. * @throws SQLException If the table does not exists. */ public static boolean isTemporaryTable(Connection connection, String tableReference) throws SQLException { TableLocation location = TableLocation.parse(tableReference); ResultSet rs = getTablesView(connection, location.getCatalog(), location.getSchema(), location.getTable()); boolean isTemporary = false; try { if(rs.next()) { String tableType; if(hasField(rs.getMetaData(), "STORAGE_TYPE")) { // H2 tableType = rs.getString("STORAGE_TYPE"); } else { // Standard SQL tableType = rs.getString("TABLE_TYPE"); } isTemporary = tableType.contains("TEMPORARY"); } else { throw new SQLException("The table "+location+" does not exists"); } } finally { rs.close(); } return isTemporary; }
if (JDBCUtilities.hasField(connection, inputTable, arg3String)) { final String weight = arg3String; if (arg4 instanceof ValueInt) {
if (JDBCUtilities.hasField(connection, inputTable, arg3String)) { final String weight = arg3String; if (arg4 instanceof ValueInt) {
if (JDBCUtilities.hasField(connection, inputTable, arg3String)) { if (arg4 instanceof ValueInt) { int source = arg4.getInt();