List of usage examples for java.sql ResultSet CONCUR_UPDATABLE
int CONCUR_UPDATABLE
To view the source code for java.sql ResultSet CONCUR_UPDATABLE.
Click Source Link
ResultSet
object that may be updated. From source file:lasige.steeldb.jdbc.BFTRowSet.java
/** * Sets the properties for this <code>CachedRowSetImpl</code> object to * their default values. This method is called internally by the * default constructor./*from ww w .ja v a 2 s . c o m*/ */ private void initProperties() throws SQLException { if (resBundle == null) { try { resBundle = JdbcRowSetResourceBundle.getJdbcRowSetResourceBundle(); } catch (IOException ioe) { throw new RuntimeException(ioe); } } setShowDeleted(false); setQueryTimeout(0); setMaxRows(0); setMaxFieldSize(0); setType(ResultSet.TYPE_SCROLL_INSENSITIVE); setConcurrency(ResultSet.CONCUR_UPDATABLE); if (rvh.size() > 0 && isReadOnly() == false) setReadOnly(false); else setReadOnly(true); setTransactionIsolation(Connection.TRANSACTION_READ_COMMITTED); setEscapeProcessing(true); setTypeMap(null); checkTransactionalWriter(); //Instantiating the vector for MatchColumns iMatchColumns = new Vector<Integer>(10); for (int i = 0; i < 10; i++) { iMatchColumns.add(i, new Integer(-1)); } strMatchColumns = new Vector<String>(10); for (int j = 0; j < 10; j++) { strMatchColumns.add(j, null); } }
From source file:org.kawanfw.sql.jdbc.ConnectionHttp.java
/** * Creates a <code>Statement</code> object that will generate * <code>ResultSet</code> objects with the given type, concurrency, and * holdability. This method is the same as the <code>createStatement</code> * method above, but it allows the default result set type, concurrency, and * holdability to be overridden.//from w w w . j a va 2 s.c o m * * @param resultSetType * one of the following <code>ResultSet</code> constants: * <code>ResultSet.TYPE_FORWARD_ONLY</code>, * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> * @param resultSetConcurrency * one of the following <code>ResultSet</code> constants: * <code>ResultSet.CONCUR_READ_ONLY</code> or * <code>ResultSet.CONCUR_UPDATABLE</code> * @param resultSetHoldability * one of the following <code>ResultSet</code> constants: * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> * @return a new <code>Statement</code> object that will generate * <code>ResultSet</code> objects with the given type, concurrency, * and holdability * @exception SQLException * if a database access error occurs, this method is called * on a closed connection or the given parameters are not * <code>ResultSet</code> constants indicating type, * concurrency, and holdability * @exception SQLFeatureNotSupportedException * if the JDBC driver does not support this method or this * method is not supported for the specified result set type, * result set holdability and result set concurrency. * @see ResultSet * @since 1.4 */ @Override public Statement createStatement(int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { testIfClosed(); // We support only ResultSet.CONCUR_READ_ONLY if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE) { throw new SQLFeatureNotSupportedException("Concurrency ResultSet.CONCUR_UPDATABLE is not supported."); } // We support only ResultSet.CLOSE_CURSORS_AT_COMMIT if (resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT) { throw new SQLFeatureNotSupportedException( "Concurrency ResultSet.HOLD_CURSORS_OVER_COMMIT is not supported."); } return new StatementHttp(this, resultSetType, resultSetConcurrency, resultSetHoldability); }
From source file:net.pms.dlna.DLNAMediaDatabase.java
public void cleanup() { Connection conn = null;// ww w.j a v a2 s . c om PreparedStatement ps = null; ResultSet rs = null; try { conn = getConnection(); ps = conn.prepareStatement("SELECT COUNT(*) FROM FILES"); rs = ps.executeQuery(); dbCount = 0; if (rs.next()) { dbCount = rs.getInt(1); } rs.close(); ps.close(); PMS.get().getFrame().setStatusLine(Messages.getString("DLNAMediaDatabase.2") + " 0%"); int i = 0; int oldpercent = 0; if (dbCount > 0) { ps = conn.prepareStatement("SELECT FILENAME, MODIFIED, ID FROM FILES", ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); rs = ps.executeQuery(); while (rs.next()) { String filename = rs.getString("FILENAME"); long modified = rs.getTimestamp("MODIFIED").getTime(); File file = new File(filename); if (!file.exists() || file.lastModified() != modified) { rs.deleteRow(); } i++; int newpercent = i * 100 / dbCount; if (newpercent > oldpercent) { PMS.get().getFrame() .setStatusLine(Messages.getString("DLNAMediaDatabase.2") + newpercent + "%"); oldpercent = newpercent; } } } } catch (SQLException se) { logger.error(null, se); } finally { close(rs); close(ps); close(conn); } }
From source file:net.sf.jasperreports.engine.query.JRJdbcQueryExecuter.java
protected static int getConcurrency(String concurrency) { if (CONCUR_READ_ONLY.equals(concurrency)) { return ResultSet.CONCUR_READ_ONLY; } else if (CONCUR_UPDATABLE.equals(concurrency)) { return ResultSet.CONCUR_UPDATABLE; }// ww w . j a v a 2s .c om return ResultSet.CONCUR_READ_ONLY; }
From source file:org.kawanfw.sql.jdbc.ConnectionHttp.java
/** * Creates a <code>CallableStatement</code> object that will generate * <code>ResultSet</code> objects with the given type and concurrency. This * method is the same as the <code>prepareCall</code> method above, but it * allows the default result set type and concurrency to be overridden. * /*w ww. j a va 2 s. c o m*/ * @param sql * a <code>String</code> object that is the SQL statement to be * sent to the database; may contain on or more ? parameters * @param resultSetType * a result set type; one of * <code>ResultSet.TYPE_FORWARD_ONLY</code>, * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> * @param resultSetConcurrency * a concurrency type; one of * <code>ResultSet.CONCUR_READ_ONLY</code> or * <code>ResultSet.CONCUR_UPDATABLE</code> * @return a new <code>CallableStatement</code> object containing the * pre-compiled SQL statement that will produce * <code>ResultSet</code> objects with the given type and * concurrency * @exception SQLException * if a database access error occurs or the given parameters * are not <code>ResultSet</code> constants indicating type * and concurrency * @since 1.2 */ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { testIfClosed(); // We support only ResultSet.CONCUR_READ_ONLY if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE) { throw new SQLFeatureNotSupportedException("Concurrency ResultSet.CONCUR_UPDATABLE is not supported."); } return new CallableStatementHttp(this, sql, resultSetType, resultSetConcurrency, getHoldability()); }
From source file:org.kawanfw.sql.jdbc.ConnectionHttp.java
/** * Creates a <code>CallableStatement</code> object that will generate * <code>ResultSet</code> objects with the given type and concurrency. This * method is the same as the <code>prepareCall</code> method above, but it * allows the default result set type, result set concurrency type and * holdability to be overridden.// ww w . jav a 2 s . c o m * * @param sql * a <code>String</code> object that is the SQL statement to be * sent to the database; may contain on or more ? parameters * @param resultSetType * one of the following <code>ResultSet</code> constants: * <code>ResultSet.TYPE_FORWARD_ONLY</code>, * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> * @param resultSetConcurrency * one of the following <code>ResultSet</code> constants: * <code>ResultSet.CONCUR_READ_ONLY</code> or * <code>ResultSet.CONCUR_UPDATABLE</code> * @param resultSetHoldability * one of the following <code>ResultSet</code> constants: * <code>ResultSet.HOLD_CURSORS_OVER_COMMIT</code> or * <code>ResultSet.CLOSE_CURSORS_AT_COMMIT</code> * @return a new <code>CallableStatement</code> object, containing the * pre-compiled SQL statement, that will generate * <code>ResultSet</code> objects with the given type, concurrency, * and holdability * @exception SQLException * if a database access error occurs or the given parameters * are not <code>ResultSet</code> constants indicating type, * concurrency, and holdability * @see ResultSet * @since 1.4 */ public CallableStatement prepareCall(String sql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { testIfClosed(); // We support only ResultSet.CONCUR_READ_ONLY if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE) { throw new SQLFeatureNotSupportedException("Concurrency ResultSet.CONCUR_UPDATABLE is not supported."); } // We support only ResultSet.CLOSE_CURSORS_AT_COMMIT if (resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT) { throw new SQLFeatureNotSupportedException( "Concurrency ResultSet.HOLD_CURSORS_OVER_COMMIT is not supported."); } return new CallableStatementHttp(this, sql, resultSetType, resultSetConcurrency, resultSetHoldability); }
From source file:org.wso2.carbon.repository.core.jdbc.dao.JDBCLogsDAO.java
public List<Activity> getLogs(String resourcePath, int action, String userName, Date from, Date to, boolean descending) throws RepositoryException { JDBCDatabaseTransaction.ManagedRegistryConnection conn = JDBCDatabaseTransaction.getConnection(); try {//from w w w .j av a 2 s. c o m String dbName = conn.getMetaData().getDatabaseProductName(); if (dbName.contains("Microsoft") || dbName.equals("Oracle")) { enableApiPagination = "false"; } } catch (SQLException e) { throw new RepositoryDBException("Failed to get Database product name ", e); } if (conn == null) { log.fatal( "Failed to get Logs. Communications link failure. The connection to the database could not be acquired."); throw new RepositoryDBException( "Failed to get Logs. Communications link failure. The connection to the database could not be acquired."); } PreparedStatement s = null; ResultSet results = null; boolean paginated = false; int start = 0; int count = 0; String sortOrder = ""; String sortBy = ""; /* MessageContext messageContext = null; // enableApiPagination is the value of system property - enable.registry.api.paginating if (enableApiPagination == null || enableApiPagination.equals("true")) { messageContext = MessageContext.getCurrentMessageContext(); if (messageContext != null && PaginationUtils.isPaginationHeadersExist(messageContext)) { PaginationContext paginationContext = PaginationUtils.initPaginationContext(messageContext); start = paginationContext.getStart(); count = paginationContext.getCount(); if(start == 0){ start =1; } sortBy = paginationContext.getSortBy(); sortOrder = paginationContext.getSortOrder(); paginated = true; } } */ String sql = "SELECT REG_PATH, REG_USER_ID, REG_LOGGED_TIME, REG_ACTION, REG_ACTION_DATA FROM REG_LOG"; boolean queryStarted = false; sql = addWherePart(resourcePath, queryStarted, sql, userName, from, to, action); if (descending) { sql = sql + " ORDER BY REG_LOGGED_TIME DESC"; } try { if (enableApiPagination == null || enableApiPagination.equals("true")) { s = conn.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE); } else { s = conn.prepareStatement(sql); } int paramNumber = 1; if (resourcePath != null) { s.setString(paramNumber, resourcePath); paramNumber++; } if (userName != null) { s.setString(paramNumber, userName); paramNumber++; } if (from != null) { s.setTimestamp(paramNumber, new Timestamp(from.getTime())); paramNumber++; } if (to != null) { s.setTimestamp(paramNumber, new Timestamp(to.getTime())); paramNumber++; } if (action != -1) { s.setInt(paramNumber, action); paramNumber++; } s.setInt(paramNumber, CurrentContext.getTenantId()); results = s.executeQuery(); List<Activity> resultList = new ArrayList<Activity>(); if (paginated) { //Check start index is a valid one if (results.relative(start)) { //This is to get cursor to correct position to execute results.next(). results.previous(); int i = 0; while (results.next() && i < count) { i++; resultList.add(getLogEntry(results)); } } else { log.debug("start index doesn't exist in the result set"); } //move the cursor to the last index if (results.last()) { log.debug("cursor move to the last index of result set"); } else { log.debug("cursor doesn't move to the last index of result set"); } //set row count to the message context. // PaginationUtils.setRowCount(messageContext, Integer.toString(results.getRow())); } else { while (results.next()) { resultList.add(getLogEntry(results)); } // Activity[] logEntries = getPaginatedLogs(resultList.toArray(new Activity[resultList.size()])); // resultList = Arrays.asList(logEntries); } return resultList; } catch (SQLException e) { String msg = "Failed to get logs. " + e.getMessage(); log.error(msg, e); throw new RepositoryDBException(msg, e); } finally { try { try { if (results != null) { results.close(); } } finally { if (s != null) { s.close(); } } } catch (SQLException ex) { String msg = InternalConstants.RESULT_SET_PREPARED_STATEMENT_CLOSE_ERROR; log.error(msg, ex); } } }
From source file:org.xenei.jdbc4sparql.J4SDatabaseMetaData.java
@Override public boolean supportsResultSetType(final int arg0) throws SQLException { switch (arg0) { case ResultSet.TYPE_FORWARD_ONLY: case ResultSet.CONCUR_READ_ONLY: case ResultSet.TYPE_SCROLL_INSENSITIVE: case ResultSet.HOLD_CURSORS_OVER_COMMIT: return true; case ResultSet.CLOSE_CURSORS_AT_COMMIT: case ResultSet.CONCUR_UPDATABLE: case ResultSet.TYPE_SCROLL_SENSITIVE: default://from w w w . ja v a2s .c o m return false; } }
From source file:org.kawanfw.sql.jdbc.ConnectionHttp.java
/** * /*from w w w . j av a 2 s .c o m*/ * Creates a <code>PreparedStatement</code> object that will generate * <code>ResultSet</code> objects with the given type and concurrency. This * method is the same as the <code>prepareStatement</code> method above, but * it allows the default result set type and concurrency to be overridden. * The holdability of the created result sets can be determined by calling * {@link #getHoldability}. * * @param sql * a <code>String</code> object that is the SQL statement to be * sent to the database; may contain one or more '?' IN * parameters * @param resultSetType * a result set type; one of * <code>ResultSet.TYPE_FORWARD_ONLY</code>, * <code>ResultSet.TYPE_SCROLL_INSENSITIVE</code>, or * <code>ResultSet.TYPE_SCROLL_SENSITIVE</code> * @param resultSetConcurrency * a concurrency type; one of * <code>ResultSet.CONCUR_READ_ONLY</code> or * <code>ResultSet.CONCUR_UPDATABLE</code> * @return a new PreparedStatement object containing the pre-compiled SQL * statement that will produce <code>ResultSet</code> objects with * the given type and concurrency * @exception SQLException * if a database access error occurs, this method is called * on a closed connection or the given parameters are not * <code>ResultSet</code> constants indicating type and * concurrency * @exception SQLFeatureNotSupportedException * if the JDBC driver does not support this method or this * method is not supported for the specified result set type * and result set concurrency. * @since 1.2 */ @Override public PreparedStatement prepareStatement(String sql, int resultSetType, int resultSetConcurrency) throws SQLException { testIfClosed(); // We support only ResultSet.CONCUR_READ_ONLY if (resultSetConcurrency == ResultSet.CONCUR_UPDATABLE) { throw new SQLFeatureNotSupportedException("Concurrency ResultSet.CONCUR_UPDATABLE is not supported."); } return new PreparedStatementHttp(this, sql, resultSetType, resultSetConcurrency, getHoldability()); }
From source file:org.springframework.jdbc.object.SqlQueryTests.java
public void testUpdateCustomers() throws SQLException { mockResultSet.next();/*www . j a v a 2 s .c o m*/ ctrlResultSet.setReturnValue(true); mockResultSet.getInt("id"); ctrlResultSet.setReturnValue(1); mockResultSet.updateString(2, "Rod"); ctrlResultSet.setVoidCallable(); mockResultSet.updateRow(); ctrlResultSet.setVoidCallable(); mockResultSet.next(); ctrlResultSet.setReturnValue(true); mockResultSet.getInt("id"); ctrlResultSet.setReturnValue(2); mockResultSet.updateString(2, "Thomas"); ctrlResultSet.setVoidCallable(); mockResultSet.updateRow(); ctrlResultSet.setVoidCallable(); mockResultSet.next(); ctrlResultSet.setReturnValue(false); mockResultSet.close(); ctrlResultSet.setVoidCallable(); mockPreparedStatement.setObject(1, new Integer(2), Types.NUMERIC); ctrlPreparedStatement.setVoidCallable(); mockPreparedStatement.executeQuery(); ctrlPreparedStatement.setReturnValue(mockResultSet); if (debugEnabled) { mockPreparedStatement.getWarnings(); ctrlPreparedStatement.setReturnValue(null); } mockPreparedStatement.close(); ctrlPreparedStatement.setVoidCallable(); mockConnection.prepareStatement(SELECT_ID_FORENAME_WHERE_ID, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE); ctrlConnection.setReturnValue(mockPreparedStatement); replay(); class CustomerUpdateQuery extends UpdatableSqlQuery { public CustomerUpdateQuery(DataSource ds) { super(ds, SELECT_ID_FORENAME_WHERE_ID); declareParameter(new SqlParameter(Types.NUMERIC)); compile(); } protected Object updateRow(ResultSet rs, int rownum, Map context) throws SQLException { rs.updateString(2, "" + context.get(new Integer(rs.getInt(COLUMN_NAMES[0])))); return null; } } CustomerUpdateQuery query = new CustomerUpdateQuery(mockDataSource); Map values = new HashMap(2); values.put(new Integer(1), "Rod"); values.put(new Integer(2), "Thomas"); List customers = query.execute(2, values); }