public String getSchemaName(Connection conn) throws SQLException { Statement stmt = conn.createStatement(); try { String stmtText = "SELECT SYS_CONTEXT('USERENV', 'CURRENT_SCHEMA') FROM DUAL"; ResultSet rs = stmt.executeQuery(stmtText); try { if (!rs.next()) { throw new NucleusDataStoreException("No result returned from " + stmtText).setFatal(); } return rs.getString(1); } finally { rs.close(); } } finally { stmt.close(); } }
public String getSchemaName(Connection conn) throws SQLException { Statement stmt = conn.createStatement(); try { String stmtText = "VALUES (CURRENT SCHEMA)"; ResultSet rs = stmt.executeQuery(stmtText); try { if (!rs.next()) { throw new NucleusDataStoreException("No result returned from " + stmtText).setFatal(); } return rs.getString(1).trim(); } finally { rs.close(); } } finally { stmt.close(); } }
public String getSchemaName(Connection conn) throws SQLException { Statement stmt = conn.createStatement(); try { String stmtText = "SELECT CURRENT_SCHEMA FROM DUAL"; ResultSet rs = stmt.executeQuery(stmtText); try { if (!rs.next()) { throw new NucleusDataStoreException("No result returned from " + stmtText).setFatal(); } return rs.getString(1); } finally { rs.close(); } } finally { stmt.close(); } }
/** * Constructor to create a column info definition for the current row of the passed ResultSet. * @param rs ResultSet (from DatabaseMetaData.getColumns() for example). * @throws NucleusDataStoreException Thrown if an error occurs getting the information */ public RDBMSColumnInfo(ResultSet rs) { try { tableCat = rs.getString(1); tableSchem = rs.getString(2); tableName = rs.getString(3); columnName = rs.getString(4); dataType = rs.getShort(5); typeName = rs.getString(6); columnSize = rs.getInt(7); decimalDigits = rs.getInt(9); numPrecRadix = rs.getInt(10); nullable = rs.getInt(11); remarks = rs.getString(12); columnDef = rs.getString(13); charOctetLength = rs.getInt(16); ordinalPosition = rs.getInt(17); isNullable = rs.getString(18); } catch (SQLException e) { throw new NucleusDataStoreException("Can't read JDBC metadata from result set", e).setFatal(); } }
throw new NucleusDataStoreException("Can't read JDBC metadata from result set", e).setFatal();
throw new NucleusDataStoreException("No result returned from " + stmtText).setFatal();
/** * Constructs an index information object from the current row of the given result set. * The {@link ResultSet} object passed must have been obtained from a call * to java.sql.DatabaseMetaData.getIndexInfo(). * @param rs The result set returned from java.sql.DatabaseMetaData.getIndexInfo(). * @exception NucleusDataStoreException if an exception occurs during retrieval */ public IndexInfo(ResultSet rs) { try { addProperty("table_cat", rs.getString(1)); addProperty("table_schem", rs.getString(2)); addProperty("table_name", rs.getString(3)); addProperty("non_unique", Boolean.valueOf(rs.getBoolean(4))); addProperty("index_name", rs.getString(6)); addProperty("type", Short.valueOf(rs.getShort(7))); addProperty("ordinal_position", Short.valueOf(rs.getShort(8))); addProperty("column_name", rs.getString(9)); // addProperty("asc_or_desc", rs.getString(10)); // "A", "D" or null } catch (SQLException e) { throw new NucleusDataStoreException("Can't read JDBC metadata from result set", e).setFatal(); } }
/** * Constructs a primary key information object from the current row of the given result set. * The {@link ResultSet} object passed must have been obtained from a call * to java.sql.DatabaseMetaData.getPrimaryKeys(). * @param rs The result set returned from java.sql.DatabaseMetaData.getPrimaryKeys(). * @exception NucleusDataStoreException if an exception occurs during retrieval */ public PrimaryKeyInfo(ResultSet rs) { try { addProperty("table_cat", rs.getString(1)); addProperty("table_schem", rs.getString(2)); addProperty("table_name", rs.getString(3)); addProperty("column_name", rs.getString(4)); addProperty("key_seq", Short.valueOf(rs.getShort(5))); addProperty("pk_name", rs.getString(6)); } catch (SQLException e) { throw new NucleusDataStoreException("Can't read JDBC metadata from result set", e).setFatal(); } }
throw new NucleusDataStoreException("Can't read JDBC metadata from result set", e).setFatal();