.getConnection("connstr", connectionProps); Statement stmt = conn.createStatement(); oracle.sql.ARRAY arr2 = new oracle.sql.ARRAY(desc2, conn, northEastRegion); PreparedStatement ps = conn.prepareStatement(str); ps.setArray(1, arr2); ps.executeQuery();
this.register = connection.registerDatabaseChangeNotification(properties); final List<DatabaseField> fields = new ArrayList<DatabaseField>(); fields.add(new DatabaseField(ROWID)); OracleStatement statement = (OracleStatement)connection.createStatement(); statement.setDatabaseChangeRegistration(this.register); try {
OracleDataSource ods = new OracleDataSource(); ods.setUser(DB_USER)); ods.setPassword(DB_PASSWORD); ods.setURL(jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(HOST=myhost)(PORT=1521)(PROTOCOL=tcp))(CONNECT_DATA=(SERVICE_NAME=myorcldbservicename)))); // New AutoClosable syntax applicable to connection. This syntax will // close the connection automatically try (OracleConnection connection = (OracleConnection) (ods.getConnection())) { // Statement and ResultSet are AutoClosable by this syntax try (Statement statement = connection.createStatement()) { try (ResultSet resultSet = statement.executeQuery("select sysdate from dual")) { while (resultSet.next()) System.out.print("Today's Date is: " + resultSet.getString(1)); } } }
/** * INTERNAL: * Remove the event listener from the database. */ public void remove(Session session) { if (this.register == null) { return; } AbstractSession databaseSession = (AbstractSession)session; Accessor accessor = databaseSession.getAccessor(); accessor.incrementCallCount(databaseSession); try { OracleConnection connection = (OracleConnection)databaseSession.getServerPlatform().unwrapConnection(accessor.getConnection()); databaseSession.log(SessionLog.FINEST, SessionLog.CONNECTION, "dcn_unregister"); try { connection.unregisterDatabaseChangeNotification(this.register); } catch (SQLException exception) { throw DatabaseException.sqlException(exception, databaseSession.getAccessor(), databaseSession, false); } } finally { accessor.decrementCallCount(); } }
try (Connection conn = ConnManager.getConnection();) { if (conn.isWrapperFor(OracleConnection.class)) { try (OracleConnection oracleConnection = conn.unwrap(OracleConnection.class); Statement stmt = oracleConnection.createStatement()) { ResultSet rs = stmt.executeQuery("select regid,callback from USER_CHANGE_NOTIFICATION_REGS"); while (rs.next()) { long regid = rs.getLong(1); String callback = rs.getString(2); ((OracleConnection) stmt.getConnection()).unregisterDatabaseChangeNotification(regid, callback); } } } } catch (SQLException ex) { Logger.getLogger(TableBase.class.getName()).log(Level.SEVERE, null, ex); }