List of usage examples for java.sql ResultSet TYPE_SCROLL_SENSITIVE
int TYPE_SCROLL_SENSITIVE
To view the source code for java.sql ResultSet TYPE_SCROLL_SENSITIVE.
Click Source Link
ResultSet
object that is scrollable and generally sensitive to changes to the data that underlies the ResultSet
. From source file:net.solarnetwork.node.dao.jdbc.AbstractBatchableJdbcDao.java
private BatchResult batchProcessInternal(final BatchCallback<T> callback, final BatchOptions options) { final String querySql = getBatchJdbcStatement(options); final AtomicInteger rowCount = new AtomicInteger(0); getJdbcTemplate().execute(new ConnectionCallback<Object>() { @Override//from ww w .j a v a 2 s. c om public net.solarnetwork.node.dao.BatchableDao.BatchResult doInConnection(Connection con) throws SQLException, DataAccessException { PreparedStatement queryStmt = null; ResultSet queryResult = null; try { queryStmt = con.prepareStatement(querySql, (options.isUpdatable() ? ResultSet.TYPE_SCROLL_SENSITIVE : ResultSet.TYPE_FORWARD_ONLY), (options.isUpdatable() ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY), ResultSet.CLOSE_CURSORS_AT_COMMIT); queryResult = queryStmt.executeQuery(); while (queryResult.next()) { T entity = getBatchRowEntity(options, queryResult, rowCount.incrementAndGet()); BatchCallbackResult rowResult = callback.handle(entity); switch (rowResult) { case CONTINUE: break; case STOP: return null; case DELETE: queryResult.deleteRow(); break; case UPDATE: case UPDATE_STOP: updateBatchRowEntity(options, queryResult, rowCount.intValue(), entity); queryResult.updateRow(); if (rowResult == BatchCallbackResult.UPDATE_STOP) { return null; } break; } } } finally { if (queryResult != null) { queryResult.close(); } if (queryStmt != null) { queryStmt.close(); } } return null; } }); return new BasicBatchResult(rowCount.intValue()); }
From source file:SyncMusicServlet.java
private void processSongData(String androidId, String title, String album, String artist, String genre) { Connection conn = null;// ww w .ja va2 s . com Statement stmt = null; PreparedStatement pstmt = null; ResultSet rs = null; try { Class.forName(JDBC_DRIVER); conn = DriverManager.getConnection(DB_URL, USER, PASS); stmt = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); // Get the albumId String sql = "select album_id from album where album_title='" + album + "'"; rs = stmt.executeQuery(sql); rs.next(); int albumId = rs.getInt("album_id"); sql = "select * from song where song_title = '" + title.replaceAll("'", "\u0027") + "'"; rs = stmt.executeQuery(sql); rs.next(); if (rs.getRow() == 0) { // Insert Song pstmt = conn.prepareStatement( "insert into song (song_title, genre, artist_name, album_id) values (?, ?, ?, ?)"); pstmt.setString(1, title.replaceAll("'", "\u0027")); pstmt.setString(2, genre); pstmt.setString(3, artist); pstmt.setInt(4, albumId); pstmt.executeUpdate(); } // Get Song Id sql = "select song_id from song where song_title='" + title.replaceAll("'", "\u0027") + "'"; rs = stmt.executeQuery(sql); rs.next(); int songId = rs.getInt("song_id"); // Check if user_music_data entry exist sql = "select * from user_music_data where song_id=" + songId + " AND android_id='" + androidId + "'"; rs = stmt.executeQuery(sql); rs.next(); if (rs.getRow() == 0) { // Insert into user_music_data sql = "insert into user_music_data (android_id, song_id) values ('" + androidId + "', " + songId + ")"; stmt.executeUpdate(sql); } //out.print(resultJSON); } catch (Exception se) { //out.println("Exception preparing or processing query: " + se); se.printStackTrace(); } finally { try { if (rs != null) { rs.close(); } if (stmt != null) { stmt.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { } } }
From source file:net.ymate.platform.persistence.jdbc.scaffold.EntityGenerator.java
/** * @param dbName ???/* www .ja v a2 s . c om*/ * @param dbUserName ?? * @param tableName ?? * @return ????? */ private TableMeta getTableMeta(String dbName, String dbUserName, String tableName) { IConnectionHolder _connHolder = null; Statement _statement = null; ResultSet _resultSet = null; Map<String, ColumnInfo> _tableFields = new LinkedHashMap<String, ColumnInfo>(); List<String> _pkFields = new LinkedList<String>(); TableMeta _meta = new TableMeta(_pkFields, _tableFields); try { _connHolder = __jdbc.getDefaultConnectionHolder(); String _dbType = _connHolder.getDialect().getName(); DatabaseMetaData _dbMetaData = _connHolder.getConnection().getMetaData(); System.out.println(">>> Catalog: " + dbName); System.out.println(">>> Schema: " + dbUserName); System.out.println(">>> Table: " + tableName); _resultSet = _dbMetaData.getPrimaryKeys(dbName, _dbType.equalsIgnoreCase("oracle") ? dbUserName.toUpperCase() : dbUserName, tableName); if (_resultSet == null) { System.err.println("Database table \"" + tableName + "\" primaryKey resultSet is null, ignored"); return null; } else { while (_resultSet.next()) { _pkFields.add(_resultSet.getString(4).toLowerCase()); } if (_pkFields.isEmpty()) { System.err .println("Database table \"" + tableName + "\" does not set the primary key, ignored"); return null; } else { // System.out.println(">>> " + "COLUMN_NAME / " + "COLUMN_CLASS_NAME / " + "PRIMARY_KEY / " + "AUTO_INCREMENT / " + "SIGNED / " + "PRECISION / " + "SCALE / " + "NULLABLE / " + "DEFAULT / " + "REMARKS"); // _statement = _connHolder.getConnection().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); _resultSet = _statement.executeQuery( "SELECT * FROM ".concat(_connHolder.getDialect().wrapIdentifierQuote(tableName))); ResultSetMetaData _rsMetaData = _resultSet.getMetaData(); // for (int _idx = 1; _idx <= _rsMetaData.getColumnCount(); _idx++) { // ?? ResultSet _column = _dbMetaData.getColumns(dbName, _dbType.equalsIgnoreCase("oracle") ? dbUserName.toUpperCase() : dbUserName, tableName, _rsMetaData.getColumnName(_idx)); if (_column.next()) { // ???? _tableFields.put(_rsMetaData.getColumnName(_idx).toLowerCase(), new ColumnInfo(_rsMetaData.getColumnName(_idx).toLowerCase(), _rsMetaData.getColumnClassName(_idx), _rsMetaData.isAutoIncrement(_idx), _rsMetaData.isSigned(_idx), _rsMetaData.getPrecision(_idx), _rsMetaData.getScale(_idx), _rsMetaData.isNullable(_idx), _column.getString("COLUMN_DEF"), _column.getString("REMARKS"))); System.out.println("--> " + _rsMetaData.getColumnName(_idx).toLowerCase() + "\t" + _rsMetaData.getColumnClassName(_idx) + "\t" + _pkFields.contains(_rsMetaData.getColumnName(_idx).toLowerCase()) + "\t" + _rsMetaData.isAutoIncrement(_idx) + "\t" + _rsMetaData.isSigned(_idx) + "\t" + _rsMetaData.getPrecision(_idx) + "\t" + _rsMetaData.getScale(_idx) + "\t" + _rsMetaData.isNullable(_idx) + "\t" + _column.getString("COLUMN_DEF") + "\t" + _column.getString("REMARKS")); } _column.close(); } } } } catch (Exception e) { if (e instanceof RuntimeException) { throw (RuntimeException) e; } throw new RuntimeException(e); } finally { if (_statement != null) { try { _statement.close(); } catch (SQLException e) { _LOG.warn("", e); } } if (_resultSet != null) { try { _resultSet.close(); } catch (SQLException e) { _LOG.warn("", e); } } if (_connHolder != null) { _connHolder.release(); } } return _meta; }
From source file:com.netspective.axiom.connection.BasicConnectionProviderEntry.java
public void init(String dataSourceId, Connection conn) { this.dataSourceId = dataSourceId; try {//from w w w . j a va 2s. c o m try { DatabasePolicy policy = DatabasePolicies.getInstance().getDatabasePolicy(conn); put(KEYNAME_DATABASE_POLICY_CLASSNAME, policy.getClass().getName()); put(KEYNAME_DATABASE_POLICY_DBMSID, policy.getDbmsIdentifier()); } catch (Exception dpe) { put(KEYNAME_DATABASE_POLICY_CLASSNAME, dpe.toString()); } DatabaseMetaData dbmd = conn.getMetaData(); put(KEYNAME_DRIVER_NAME, dbmd.getDriverName()); put(KEYNAME_DATABASE_PRODUCT_NAME, dbmd.getDatabaseProductName()); put(KEYNAME_DATABASE_PRODUCT_VERSION, dbmd.getDatabaseProductVersion()); put(KEYNAME_DRIVER_VERSION, dbmd.getDriverVersion()); put(KEYNAME_URL, dbmd.getURL()); put(KEYNAME_USER_NAME, dbmd.getUserName()); String resultSetType = "unknown"; if (dbmd.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)) resultSetType = "scrollable (insensitive)"; else if (dbmd.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE)) resultSetType = "scrollable (sensitive)"; else if (dbmd.supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY)) resultSetType = "non-scrollabe (forward only)"; put(KEYNAME_RESULTSET_TYPE, resultSetType); valid = true; } catch (Exception e) { exception = e; } finally { try { conn.close(); } catch (SQLException e) { log.error("SQL Exception while closing connection", e); } } }
From source file:edu.ku.brc.af.core.db.MySQLBackupService.java
public int getNumberofTables() { Connection dbConnection = null; Statement dbStatement = null; try {// www. ja va 2 s. c o m dbConnection = DBConnection.getInstance().createConnection(); if (dbConnection != null) { dbStatement = dbConnection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = dbStatement.executeQuery("SHOW TABLES"); ResultSetMetaData metaData = resultSet.getMetaData(); numTables = 0; while (resultSet.next()) { for (int i = 0; i < metaData.getColumnCount(); i++) { numTables++; } } resultSet.close(); return numTables; } } catch (SQLException ex) { ex.printStackTrace(); } finally { try { if (dbStatement != null) { dbStatement.close(); } if (dbConnection != null) { dbConnection.close(); } } catch (SQLException ex) { ex.printStackTrace(); } } return -1; }
From source file:net.pms.database.TableMusicBrainzReleases.java
/** * Stores the MBID with information from this {@link Tag} in the database * * @param mBID the MBID to store/*from w ww.j a va 2 s.c o m*/ * @param tag the {@link Tag} who's information should be associated with * the given MBID */ public static void writeMBID(final String mBID, final CoverArtArchiveTagInfo tagInfo) { boolean trace = LOGGER.isTraceEnabled(); try (Connection connection = database.getConnection()) { String query = "SELECT * FROM " + TABLE_NAME + constructTagWhere(tagInfo, true); if (trace) { LOGGER.trace("Searching for release MBID with \"{}\" before update", query); } tableLock.writeLock().lock(); try (Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)) { connection.setAutoCommit(false); try (ResultSet result = statement.executeQuery(query)) { if (result.next()) { if (StringUtil.hasValue(mBID) || !StringUtil.hasValue(result.getString("MBID"))) { if (trace) { LOGGER.trace("Updating row {} to MBID \"{}\"", result.getInt("ID"), mBID); } result.updateTimestamp("MODIFIED", new Timestamp(System.currentTimeMillis())); if (StringUtil.hasValue(mBID)) { result.updateString("MBID", mBID); } else { result.updateNull("MBID"); } result.updateRow(); } else if (trace) { LOGGER.trace("Leaving row {} alone since previous information seems better", result.getInt("ID")); } } else { if (trace) { LOGGER.trace( "Inserting new row for MBID \"{}\":\n" + " Artist \"{}\"\n" + " Album \"{}\"\n" + " Title \"{}\"\n" + " Year \"{}\"\n" + " Artist ID \"{}\"\n" + " Track ID \"{}\"\n", mBID, tagInfo.artist, tagInfo.album, tagInfo.title, tagInfo.year, tagInfo.artistId, tagInfo.trackId); } result.moveToInsertRow(); result.updateTimestamp("MODIFIED", new Timestamp(System.currentTimeMillis())); if (StringUtil.hasValue(mBID)) { result.updateString("MBID", mBID); } if (StringUtil.hasValue(tagInfo.album)) { result.updateString("ALBUM", left(tagInfo.album, 1000)); } if (StringUtil.hasValue(tagInfo.artist)) { result.updateString("ARTIST", left(tagInfo.artist, 1000)); } if (StringUtil.hasValue(tagInfo.title)) { result.updateString("TITLE", left(tagInfo.title, 1000)); } if (StringUtil.hasValue(tagInfo.year)) { result.updateString("YEAR", left(tagInfo.year, 20)); } if (StringUtil.hasValue(tagInfo.artistId)) { result.updateString("ARTIST_ID", tagInfo.artistId); } if (StringUtil.hasValue(tagInfo.trackId)) { result.updateString("TRACK_ID", tagInfo.trackId); } result.insertRow(); } } finally { connection.commit(); } } finally { tableLock.writeLock().unlock(); } } catch (SQLException e) { LOGGER.error("Database error while writing Music Brainz ID \"{}\" for \"{}\": {}", mBID, tagInfo, e.getMessage()); LOGGER.trace("", e); } }
From source file:com.oracle.tutorial.jdbc.CoffeesTable.java
public void modifyPrices(float percentage) throws SQLException { Statement stmt = null;/*from w w w .j a va 2 s .c o m*/ try { stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet uprs = stmt.executeQuery("SELECT * FROM COFFEES"); while (uprs.next()) { float f = uprs.getFloat("PRICE"); uprs.updateFloat("PRICE", f * percentage); uprs.updateRow(); } } catch (SQLException e) { JDBCTutorialUtilities.printSQLException(e); } finally { if (stmt != null) { stmt.close(); } } }
From source file:com.google.enterprise.connector.salesforce.storetype.DBStore.java
public DBStore(BaseConnector connector) { Connection connection = null; logger = Logger.getLogger(this.getClass().getPackage().getName()); logger.log(Level.INFO, "Initialize DBStore "); this.connector = connector; //each connector instance has its own table in the same database this.instance_table = "i_" + connector.getInstanceName(); Statement Stmt = null;// w w w .j a v a 2s.co m ResultSet RS = null; DatabaseMetaData dbm = null; boolean table_exists = false; try { //check if the datasource/database exists Context initCtx = new InitialContext(); Context envCtx = (Context) initCtx.lookup("java:comp/env"); ds = (DataSource) envCtx.lookup(BaseConstants.CONNECTOR_DATASOURCE); connection = ds.getConnection(); connection.setAutoCommit(true); dbm = connection.getMetaData(); logger.log(Level.INFO, "Connected to databaseType " + dbm.getDatabaseProductName()); } catch (Exception ex) { logger.log(Level.SEVERE, "Exception initializing Store Datasource " + ex); connection = null; return; } try { if (dbm.getDatabaseProductName().equals("MySQL")) { //check if the per-connector table exists logger.log(Level.FINE, "Checking to see if connector DB exists..."); Stmt = connection.createStatement(); RS = Stmt.executeQuery("desc " + instance_table); ResultSetMetaData rsMetaData = RS.getMetaData(); if (rsMetaData.getColumnCount() > 0) table_exists = true; RS.close(); Stmt.close(); } else { logger.log(Level.SEVERE, "Unsupported DATABASE TYPE..." + dbm.getDatabaseProductName()); } } catch (Exception ex) { logger.log(Level.SEVERE, "Exception initializing Store " + ex); } try { //if the per-instance table doesn't exist, create it if (!table_exists) { logger.log(Level.INFO, "Creating Instance Table " + instance_table); if (dbm.getDatabaseProductName().equals("MySQL")) { Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); String create_stmt = ""; create_stmt = "CREATE TABLE `" + this.instance_table + "` (" + "`crawl_set` decimal(19,5) NOT NULL," + "`insert_timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP," + "`crawl_data` MEDIUMTEXT default NULL," + "PRIMARY KEY (`crawl_set`)," + "KEY `set_index` (`crawl_set`)" + ") ENGINE=MyISAM;"; statement.addBatch(create_stmt); statement.executeBatch(); statement.close(); } else { logger.log(Level.INFO, "Instance Table " + instance_table + " already exists"); //connection.close(); //TODO: somehow figure out if we should delete this table here } } boolean qrtz_table_exists = false; if (dbm.getDatabaseProductName().equals("MySQL")) { //check if the per-connector table exists logger.log(Level.FINE, "Checking to see if quartz tables exists..."); Stmt = connection.createStatement(); try { RS = Stmt.executeQuery("desc QRTZ_JOB_DETAILS"); ResultSetMetaData rsMetaData = RS.getMetaData(); if (rsMetaData.getColumnCount() > 0) qrtz_table_exists = true; } catch (Exception ex) { logger.log(Level.INFO, "Could not find Quartz Tables...creating now.."); } RS.close(); Stmt.close(); } else { logger.log(Level.SEVERE, "Unsupported DATABASE TYPE..." + dbm.getDatabaseProductName()); } if (!qrtz_table_exists) { logger.log(Level.INFO, "Creating Global Quartz Table "); //the quartz db setup scripts are at //quartz-1.8.0/docs/dbTables/tables_mysql.sql //one set of Quartz tables can handle any number of triggers/crons Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); String create_stmt = "CREATE TABLE QRTZ_JOB_DETAILS (JOB_NAME VARCHAR(200) NOT NULL,JOB_GROUP VARCHAR(200) NOT NULL,DESCRIPTION VARCHAR(250) NULL,JOB_CLASS_NAME VARCHAR(250) NOT NULL,IS_DURABLE VARCHAR(1) NOT NULL,IS_VOLATILE VARCHAR(1) NOT NULL,IS_STATEFUL VARCHAR(1) NOT NULL,REQUESTS_RECOVERY VARCHAR(1) NOT NULL,JOB_DATA BLOB NULL,PRIMARY KEY (JOB_NAME,JOB_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_JOB_LISTENERS ( JOB_NAME VARCHAR(200) NOT NULL, JOB_GROUP VARCHAR(200) NOT NULL, JOB_LISTENER VARCHAR(200) NOT NULL, PRIMARY KEY (JOB_NAME,JOB_GROUP,JOB_LISTENER), FOREIGN KEY (JOB_NAME,JOB_GROUP) REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_FIRED_TRIGGERS ( ENTRY_ID VARCHAR(95) NOT NULL, TRIGGER_NAME VARCHAR(200) NOT NULL, TRIGGER_GROUP VARCHAR(200) NOT NULL, IS_VOLATILE VARCHAR(1) NOT NULL, INSTANCE_NAME VARCHAR(200) NOT NULL, FIRED_TIME BIGINT(13) NOT NULL, PRIORITY INTEGER NOT NULL, STATE VARCHAR(16) NOT NULL, JOB_NAME VARCHAR(200) NULL, JOB_GROUP VARCHAR(200) NULL, IS_STATEFUL VARCHAR(1) NULL, REQUESTS_RECOVERY VARCHAR(1) NULL, PRIMARY KEY (ENTRY_ID));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_TRIGGERS ( TRIGGER_NAME VARCHAR(200) NOT NULL, TRIGGER_GROUP VARCHAR(200) NOT NULL, JOB_NAME VARCHAR(200) NOT NULL, JOB_GROUP VARCHAR(200) NOT NULL, IS_VOLATILE VARCHAR(1) NOT NULL, DESCRIPTION VARCHAR(250) NULL, NEXT_FIRE_TIME BIGINT(13) NULL, PREV_FIRE_TIME BIGINT(13) NULL, PRIORITY INTEGER NULL, TRIGGER_STATE VARCHAR(16) NOT NULL, TRIGGER_TYPE VARCHAR(8) NOT NULL, START_TIME BIGINT(13) NOT NULL, END_TIME BIGINT(13) NULL, CALENDAR_NAME VARCHAR(200) NULL, MISFIRE_INSTR SMALLINT(2) NULL, JOB_DATA BLOB NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (JOB_NAME,JOB_GROUP) REFERENCES QRTZ_JOB_DETAILS(JOB_NAME,JOB_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_SIMPLE_TRIGGERS ( TRIGGER_NAME VARCHAR(200) NOT NULL, TRIGGER_GROUP VARCHAR(200) NOT NULL, REPEAT_COUNT BIGINT(7) NOT NULL, REPEAT_INTERVAL BIGINT(12) NOT NULL, TIMES_TRIGGERED BIGINT(10) NOT NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_CRON_TRIGGERS ( TRIGGER_NAME VARCHAR(200) NOT NULL, TRIGGER_GROUP VARCHAR(200) NOT NULL, CRON_EXPRESSION VARCHAR(200) NOT NULL, TIME_ZONE_ID VARCHAR(80), PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_BLOB_TRIGGERS ( TRIGGER_NAME VARCHAR(200) NOT NULL, TRIGGER_GROUP VARCHAR(200) NOT NULL, BLOB_DATA BLOB NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_TRIGGER_LISTENERS ( TRIGGER_NAME VARCHAR(200) NOT NULL, TRIGGER_GROUP VARCHAR(200) NOT NULL, TRIGGER_LISTENER VARCHAR(200) NOT NULL, PRIMARY KEY (TRIGGER_NAME,TRIGGER_GROUP,TRIGGER_LISTENER), FOREIGN KEY (TRIGGER_NAME,TRIGGER_GROUP) REFERENCES QRTZ_TRIGGERS(TRIGGER_NAME,TRIGGER_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_CALENDARS ( CALENDAR_NAME VARCHAR(200) NOT NULL, CALENDAR BLOB NOT NULL, PRIMARY KEY (CALENDAR_NAME));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_PAUSED_TRIGGER_GRPS ( TRIGGER_GROUP VARCHAR(200) NOT NULL, PRIMARY KEY (TRIGGER_GROUP));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_SCHEDULER_STATE ( INSTANCE_NAME VARCHAR(200) NOT NULL, LAST_CHECKIN_TIME BIGINT(13) NOT NULL, CHECKIN_INTERVAL BIGINT(13) NOT NULL, PRIMARY KEY (INSTANCE_NAME));"; statement.addBatch(create_stmt); create_stmt = "CREATE TABLE QRTZ_LOCKS ( LOCK_NAME VARCHAR(40) NOT NULL, PRIMARY KEY (LOCK_NAME));"; statement.addBatch(create_stmt); create_stmt = "INSERT INTO QRTZ_LOCKS values('TRIGGER_ACCESS');"; statement.addBatch(create_stmt); create_stmt = "INSERT INTO QRTZ_LOCKS values('JOB_ACCESS');"; statement.addBatch(create_stmt); create_stmt = "INSERT INTO QRTZ_LOCKS values('CALENDAR_ACCESS');"; statement.addBatch(create_stmt); create_stmt = "INSERT INTO QRTZ_LOCKS values('STATE_ACCESS');"; statement.addBatch(create_stmt); create_stmt = "INSERT INTO QRTZ_LOCKS values('MISFIRE_ACCESS');"; statement.addBatch(create_stmt); statement.executeBatch(); statement.close(); } else { logger.log(Level.INFO, "Global Quartz Table already exists "); } connection.close(); } catch (Exception ex) { logger.log(Level.SEVERE, "Exception Creating StoreTable " + ex); } }
From source file:org.pentaho.reporting.engine.classic.core.modules.misc.datafactory.sql.SimpleSQLReportDataFactory.java
private int getBestResultSetType(final DataRow dataRow) throws SQLException { if ("simple".equalsIgnoreCase(getConfiguration().getConfigProperty( //$NON-NLS-1$ ResultSetTableModelFactory.RESULTSET_FACTORY_MODE))) { //$NON-NLS-1$ return ResultSet.TYPE_FORWARD_ONLY; }//from www . ja v a2 s .c o m final Connection connection = getConnection(dataRow); final boolean supportsScrollInsensitive = connection.getMetaData() .supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE); final boolean supportsScrollSensitive = connection.getMetaData() .supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE); if (supportsScrollInsensitive) { return ResultSet.TYPE_SCROLL_INSENSITIVE; } if (supportsScrollSensitive) { return ResultSet.TYPE_SCROLL_SENSITIVE; } return ResultSet.TYPE_FORWARD_ONLY; }
From source file:gov.nih.nci.migration.MigrationDriver.java
private void encryptDecryptApplicationInformation() throws EncryptionException, SQLException { Connection connection = getConnection(); Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); ResultSet resultSet = null;// w w w . j a va 2s . c o m if ("oracle".equals(DATABASE_TYPE)) { resultSet = stmt.executeQuery("SELECT CSM_APPLICATION.* FROM CSM_APPLICATION FOR UPDATE"); } else { resultSet = stmt.executeQuery("SELECT * FROM CSM_APPLICATION"); } String databasePassword = null; String encryptedDatabasePassword = null; while (resultSet.next()) { databasePassword = resultSet.getString("DATABASE_PASSWORD"); if (!StringUtilities.isBlank(databasePassword)) { String orgPasswordStr = desEncryption.decrypt(databasePassword); encryptedDatabasePassword = aesEncryption.encrypt(orgPasswordStr); if (!StringUtilities.isBlank(encryptedDatabasePassword)) { resultSet.updateString("DATABASE_PASSWORD", encryptedDatabasePassword); } } System.out.println("Updating Application:" + resultSet.getString("APPLICATION_NAME")); resultSet.updateRow(); } }