List of usage examples for java.sql ResultSet getStatement
Statement getStatement() throws SQLException;
Statement
object that produced this ResultSet
object. From source file:com.runwaysdk.dataaccess.database.general.SQLServer.java
/** * @see com.runwaysdk.dataaccess.database.Database#nonUniqueAttributeExists(String, String, String); */// w w w. ja va 2s. co m @Override public boolean nonUniqueAttributeExists(String table, String columnName, String indexName) { String sqlStmt = "sp_helpindex " + table; ResultSet resultSet = query(sqlStmt); boolean returnResult = false; try { while (resultSet.next()) { /* column name */ String attrName = resultSet.getString("index_keys").toLowerCase(); String keyName = resultSet.getString("index_name").toLowerCase(); if (keyName.equals(indexName) && attrName.equals(columnName.toLowerCase())) { returnResult = true; } } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }
From source file:com.runwaysdk.dataaccess.database.general.Oracle.java
/** * @see com.runwaysdk.dataaccess.AbstractDatabase#getNextSequenceNumber() */// w ww . j a v a 2 s .c o m public String getNextSequenceNumber() { // get the sequence value String sqlStmt = "SELECT " + this.objectSequenceName + ".nextval AS nextval FROM DUAL"; ResultSet resultSet = query(sqlStmt); String returnResult = ""; try { resultSet.next(); return resultSet.getString("nextval"); } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }
From source file:com.runwaysdk.dataaccess.database.general.Oracle.java
/** * @see com.runwaysdk.dataaccess.AbstractDatabase#getNextTransactionSequence() *//*from w w w.j a va 2 s. c o m*/ @Override public String getNextTransactionSequence() { // get the sequence value String sqlStmt = "SELECT " + this.transactionSequenceName + ".nextval AS nextval FROM DUAL"; ResultSet resultSet = query(sqlStmt); String returnResult = ""; try { resultSet.next(); return resultSet.getString("nextval"); } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }
From source file:com.runwaysdk.dataaccess.database.general.Oracle.java
/** * Returns true if a group attribute index exists with the given name on the given table. * @param tableName//ww w. ja va 2s . co m * @param indexName */ public boolean groupAttributeIndexExists(String table, String indexName) { String sqlStmt = " SELECT column_name \n" + " FROM user_ind_columns \n" + " WHERE index_name = '" + indexName.toUpperCase() + "' \n"; ResultSet resultSet = query(sqlStmt); boolean returnValue = false; try { if (resultSet.next()) { returnValue = true; } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnValue; }
From source file:com.runwaysdk.dataaccess.database.general.Oracle.java
/** * @see com.runwaysdk.dataaccess.AbstractDatabase#tableExists(java.lang.String) *///from ww w . ja va 2 s . co m public boolean tableExists(String tableName) { String sqlStmt = "SELECT table_name FROM user_tables WHERE table_name = '" + tableName.toUpperCase() + "'"; ResultSet resultSet = query(sqlStmt); boolean returnResult = false; try { if (resultSet.next()) { returnResult = true; } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }
From source file:com.runwaysdk.dataaccess.database.general.Oracle.java
/** * @see com.runwaysdk.dataaccess.database.Database#uniqueAttributeExists(String, String, String); *///from www .j av a2s . c o m public boolean uniqueAttributeExists(String table, String columnName, String indexName) { String sqlStmt = "SELECT column_name \n" + " FROM user_ind_columns \n" + " WHERE index_name = '" + indexName.toUpperCase() + "' \n" + " AND column_name = '" + columnName.toUpperCase() + "'"; ResultSet resultSet = query(sqlStmt); boolean returnResult = false; try { if (resultSet.next()) { returnResult = true; } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }
From source file:com.runwaysdk.dataaccess.database.general.Oracle.java
/** * Returns true if the given index exists on the given table, false otherwise. * * @param table/*from w w w. j av a 2 s. c om*/ * @param indexName * @return true if the given index exists on the given table, false otherwise. */ public boolean indexExists(String table, String indexName) { String sqlStmt = " SELECT column_name \n" + " FROM user_ind_columns \n" + " WHERE index_name = '" + indexName.toUpperCase() + "' \n"; ResultSet resultSet = query(sqlStmt); boolean returnResult = false; try { if (resultSet.next()) { returnResult = true; } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }
From source file:com.runwaysdk.dataaccess.database.general.Oracle.java
/** * Returns the name of the table on which the given index applies. * @param indexName//from w w w. j a v a 2 s . c o m * @param conx * @return name of the table on which the given index applies. */ public String getTableNameForIndex(String indexName, Connection conx) { String sqlStmt = " SELECT table_name \n" + " FROM user_ind_columns \n" + " WHERE index_name = '" + indexName.toUpperCase() + "' \n " + " AND ROWNUM = 1"; ResultSet resultSet = query(sqlStmt); String tableName = ""; try { while (resultSet.next()) { tableName = resultSet.getString("table_name").toLowerCase(); } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return tableName; }
From source file:com.runwaysdk.dataaccess.database.general.MySQL.java
/** * @see com.runwaysdk.dataaccess.database.Database#uniqueAttributeExists(String, * String, String);// w w w.j a va2 s .com */ public boolean uniqueAttributeExists(String table, String columnName, String indexName) { String sqlStmt = "SHOW INDEX FROM " + table; ResultSet resultSet = query(sqlStmt); boolean returnResult = false; try { while (resultSet.next()) { String attrName = resultSet.getString("column_name").toLowerCase(); String keyName = resultSet.getString("key_name").toLowerCase(); String nonUnique = resultSet.getString("non_unique").toLowerCase(); if (keyName.equals(indexName) && attrName.equals(columnName.toLowerCase()) && nonUnique.equals("0")) { returnResult = true; } } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }
From source file:com.runwaysdk.dataaccess.database.general.MySQL.java
/** * @see com.runwaysdk.dataaccess.database.Database#nonUniqueAttributeExists(String, * String, String);//from www . j ava2 s . c o m */ public boolean nonUniqueAttributeExists(String table, String columnName, String indexName) { String sqlStmt = "SHOW INDEX FROM " + table; ResultSet resultSet = query(sqlStmt); boolean returnResult = false; try { while (resultSet.next()) { String attrName = resultSet.getString("column_name").toLowerCase(); String keyName = resultSet.getString("key_name").toLowerCase(); String nonUnique = resultSet.getString("non_unique").toLowerCase(); if (keyName.equals(indexName) && attrName.equals(columnName.toLowerCase()) && nonUnique.equals("1")) { returnResult = true; } } } catch (SQLException sqlEx1) { Database.throwDatabaseException(sqlEx1); } finally { try { java.sql.Statement statement = resultSet.getStatement(); resultSet.close(); statement.close(); } catch (SQLException sqlEx2) { Database.throwDatabaseException(sqlEx2); } } return returnResult; }