List of usage examples for java.sql ResultSet findColumn
int findColumn(String columnLabel) throws SQLException;
ResultSet
column label to its ResultSet
column index. From source file:org.springframework.orm.hibernate.support.AbstractLobType.java
/** * This implementation delegates to nullSafeGetInternal, * passing in the LobHandler of this type. * @see #nullSafeGetInternal//from w ww . j a v a 2 s . co m */ public final Object nullSafeGet(ResultSet rs, String[] names, Object owner) throws HibernateException, SQLException { if (this.lobHandler == null) { throw new IllegalStateException("No LobHandler found for configuration - " + "lobHandler property must be set on LocalSessionFactoryBean"); } try { return nullSafeGetInternal(rs, rs.findColumn(names[0]), this.lobHandler); } catch (IOException ex) { throw new HibernateException("I/O errors during LOB access", ex); } }
From source file:org.wso2.carbon.is.migration.service.v550.dao.OAuthDAO.java
public boolean isConsumerSecretHashColumnAvailable(Connection connection) throws MigrationClientException { String sql;//from w w w. j a va 2s . c o m boolean isConsumerSecretHashColumnsExist = false; try { if (connection.getMetaData().getDriverName().contains("MySQL") || connection.getMetaData().getDriverName().contains("H2")) { sql = RETRIEVE_CONSUMER_APPS_TABLE_MYSQL; } else if (connection.getMetaData().getDatabaseProductName().contains("DB2")) { sql = RETRIEVE_CONSUMER_APPS_TABLE_DB2SQL; } else if (connection.getMetaData().getDriverName().contains("MS SQL") || connection.getMetaData().getDriverName().contains("Microsoft")) { sql = RETRIEVE_CONSUMER_APPS_TABLE_MSSQL; } else if (connection.getMetaData().getDriverName().contains("PostgreSQL")) { sql = RETRIEVE_CONSUMER_APPS_TABLE_MYSQL; } else if (connection.getMetaData().getDriverName().contains("Informix")) { // Driver name = "IBM Informix JDBC Driver for IBM Informix Dynamic Server" sql = RETRIEVE_CONSUMER_APPS_TABLE_INFORMIX; } else { sql = RETRIEVE_CONSUMER_APPS_TABLE_ORACLE; } } catch (Exception e) { throw new MigrationClientException("Error while retrieving metadata from connection.", e); } try (PreparedStatement preparedStatement = connection.prepareStatement(sql)) { try { ResultSet resultSet = preparedStatement.executeQuery(); if (resultSet != null) { resultSet.findColumn(CONSUMER_SECRET_HASH); isConsumerSecretHashColumnsExist = true; } } catch (SQLException e) { isConsumerSecretHashColumnsExist = false; log.error("Error occured while executing the PreparedStatement." + e.getMessage()); } } catch (SQLException e) { isConsumerSecretHashColumnsExist = false; log.error("Error occured while creating the PreparedStatement." + e.getMessage()); } return isConsumerSecretHashColumnsExist; }