List of usage examples for java.sql ResultSet CONCUR_READ_ONLY
int CONCUR_READ_ONLY
To view the source code for java.sql ResultSet CONCUR_READ_ONLY.
Click Source Link
ResultSet
object that may NOT be updated. From source file:com.couchbase.CBConnection.java
/** * 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}.//from ww w. j a v a 2s.c o m * * @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 * @throws java.sql.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 * @throws java.sql.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 { checkClosed(); if (resultSetType == ResultSet.TYPE_FORWARD_ONLY && resultSetConcurrency == ResultSet.CONCUR_READ_ONLY) return prepareStatement(sql); else throw CBDriver.notImplemented(CBConnection.class, "prepareStatement"); }
From source file:de.innovationgate.webgate.api.jdbc.custom.JDBCSource.java
private ResultSet getTableResultSet(String folder, String specify, boolean updatable) throws SQLException { if (!_tables.containsKey(folder.toLowerCase())) { return null; }/*w ww. ja v a2s . c o m*/ StringBuffer query = new StringBuffer(); query.append("SELECT * FROM " + folder); if (specify != null) { query.append(" WHERE ").append(specify); } Statement stmt = getConnection().createStatement(_resultSetType, (updatable ? ResultSet.CONCUR_UPDATABLE : ResultSet.CONCUR_READ_ONLY)); stmt.execute(query.toString()); ResultSet resultSet = stmt.getResultSet(); return resultSet; }
From source file:fr.bird.bloom.model.GeographicTreatment.java
/** * Select wrong geospatial and write in a file : * tag "hasGeospatialIssues_" = true//from w w w .ja va 2s . com * * @return File wrong geospatial */ public List<String> deleteWrongGeospatial() { Statement statement = null; try { statement = ConnectionDatabase.getConnection().createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } DatabaseTreatment newConnection = new DatabaseTreatment(statement); List<String> messages = new ArrayList<>(); messages.add("\n--- Select wrong geospatialIssues ---"); String sqlRetrieveWrongGeo = "SELECT abstract_,acceptedNameUsage_,acceptedNameUsageID_,accessRights_,accrualMethod_,accrualPeriodicity_,accrualPolicy_,alternative_,associatedMedia_,associatedOccurrences_,associatedOrganisms_,associatedReferences_,associatedSequences_,associatedTaxa_,audience_,available_,basisOfRecord_,bed_,behavior_,bibliographicCitation_,catalogNumber_,class_,classKey_,collectionCode_,collectionID_,conformsTo_,continent_,contributor_,coordinateAccuracy_,coordinatePrecision_,coordinateUncertaintyInMeters_,country_,countryCode_,county_,coverage_,created_,creator_,dataGeneralizations_,datasetID_,datasetKey_,datasetName_,date_,dateAccepted_,dateCopyrighted_,dateIdentified_,dateSubmitted_,day_,decimalLatitude_,decimalLongitude_,depth_,depthAccuracy_,description_,disposition_,distanceAboveSurface_,distanceAboveSurfaceAccuracy_,dynamicProperties_,earliestAgeOrLowestStage_,earliestEonOrLowestEonothem_,earliestEpochOrLowestSeries_,earliestEraOrLowestErathem_,earliestPeriodOrLowestSystem_,educationLevel_,elevation_,elevationAccuracy_,endDayOfYear_,establishmentMeans_,event_,eventDate_,eventID_,eventRemarks_,eventTime_,extent_,family_,familyKey_,fieldNotes_,fieldNumber_,footprintSpatialFit_,footprintSRS_,footprintWKT_,format_,formation_,gbifID_,genericName_,genus_,genusKey_,geodeticDatum_,geologicalContext_,geologicalContextID_,georeferencedBy_,georeferencedDate_,georeferenceProtocol_,georeferenceRemarks_,georeferenceSources_,georeferenceVerificationStatus_,group_,habitat_,hasCoordinate_,hasFormat_,hasGeospatialIssues_,hasPart_,hasVersion_,higherClassification_,higherGeography_,higherGeographyID_,highestBiostratigraphicZone_,identification_,identificationID_,identificationQualifier_,identificationReferences_,identificationRemarks_,identificationVerificationStatus_,identifiedBy_,identifier_,idFile_,individualCount_,individualID_,informationWithheld_,infraspecificEpithet_,institutionCode_,institutionID_,instructionalMethod_,isFormatOf_,island_,islandGroup_,isPartOf_,isReferencedBy_,isReplacedBy_,isRequiredBy_,issue_,issued_,isVersionOf_,kingdom_,kingdomKey_,language_,lastCrawled_,lastInterpreted_,lastParsed_,latestAgeOrHighestStage_,latestEonOrHighestEonothem_,latestEpochOrHighestSeries_,latestEraOrHighestErathem_,latestPeriodOrHighestSystem_,license_,lifeStage_,lithostratigraphicTerms_,livingSpecimen_,locality_,locationAccordingTo_,locationID_,locationRemarks_,lowestBiostratigraphicZone_,machineObservation_,materialSample_,materialSampleID_,maximumDepthinMeters_,maximumDistanceAboveSurfaceInMeters_,maximumElevationInMeters_,measurementAccuracy_,measurementDeterminedBy_,measurementDeterminedDate_,measurementID_,measurementMethod_,measurementOrFact_,measurementRemarks_,measurementType_,measurementUnit_,mediator_,mediaType_,medium_,member_,minimumDepthinMeters_,minimumDistanceAboveSurfaceInMeters_,minimumElevationInMeters_,modified_,month_,municipality_,nameAccordingTo_,nameAccordingToID_,namePublishedIn_,namePublishedInID_,namePublishedInYear_,nomenclaturalCode_,nomenclaturalStatus_,occurrence_,occurrenceDetails_,occurrenceID_,occurrenceRemarks_,occurrenceStatus_,order_,orderKey_,organism_,organismID_,organismName_,organismRemarks_,organismScope_,originalNameUsage_,originalNameUsageID_,otherCatalogNumbers_,ownerInstitutionCode_,parentNameUsage_,parentNameUsageID_,phylum_,phylumKey_,pointRadiusSpatialFit_,preparations_,preservedSpecimen_,previousIdentifications_,protocol_,provenance_,publisher_,publishingCountry_,recordedBy_,recordNumber_,references_,relatedResourceID_,relationshipAccordingTo_,relationshipEstablishedDate_,relationshipRemarks_,relation_,replaces_,reproductiveCondition_,requires_,resourceID_,resourceRelationship_,resourceRelationshipID_,rights_,rightsHolder_,samplingEffort_,samplingProtocol_,scientificName_,scientificNameAuthorship_,scientificNameID_,sex_,source_,spatial_,species_,speciesKey_,specificEpithet_,startDayOfYear_,stateProvince_,subgenus_,subgenusKey_,subject_,tableOfContents_,taxon_,taxonConceptID_,taxonID_,taxonKey_,taxonomicStatus_,taxonRank_,taxonRemarks_,temporal_,title_,type_,typeStatus_,typifiedName_,valid_,verbatimCoordinates_,verbatimCoordinateSystem_,verbatimDate_,verbatimDepth_,verbatimElevation_,verbatimEventDate_,verbatimLatitude_,verbatimLocality_,verbatimLongitude_,verbatimSRS_,verbatimTaxonRank_,vernacularName_,waterBody_,year_ FROM Workflow.DarwinCoreInput WHERE (UUID_=\"" + this.getUuid() + "\") AND hasGeospatialIssues_='true' AND !(decimalLatitude_=0 OR decimalLatitude_>90 OR decimalLatitude_<-90 OR decimalLongitude_=0 OR decimalLongitude_>180 OR decimalLongitude_<-180);"; messages.addAll(newConnection.executeSQLcommand("executeQuery", sqlRetrieveWrongGeo)); List<String> resultatSelect = newConnection.getResultatSelect(); messages.add("nb lignes affectes : " + Integer.toString(resultatSelect.size() - 1)); this.setNbWrongGeospatialIssues(resultatSelect.size() - 1); if (!new File(BloomConfig.getDirectoryPath() + "temp/" + this.getUuid() + "/wrong/").exists()) { BloomUtils.createDirectory(BloomConfig.getDirectoryPath() + "temp/" + this.getUuid() + "/wrong/"); } for (int j = 0; j < messages.size(); j++) { System.out.println(messages.get(j)); } this.setNbWrongGeospatialIssues(resultatSelect.size() - 1); return resultatSelect; }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BlobDefTable.java
public MSSBamBlobDefBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) { final String S_ProcName = "MSSBamPg8BlobDefTable.readDerivedByUNameIdx() "; MSSBamBlobDefBuff buff;/*from w w w . j ava 2 s .c om*/ if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectBlobDefDistinctClassCode + "WHERE " + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ") + "AND " + "anyo.Name = " + MSSBamPg8Schema.getQuotedString(Name) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { classCode = resultSet.getString(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (classCode.equals("BLB")) { buff = readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TBLB")) { buff = schema.getTableTableBlob().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("SBLB")) { buff = schema.getTableSchemaBlob().readBuffByUNameIdx(Authorization, ScopeId, Name); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } return (buff); }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BoolDefTable.java
public MSSBamBoolDefBuff[] readDerivedByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) { final String S_ProcName = "readDerivedByVContIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }//from w w w . ja v a 2 s. com ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectBoolDefDistinctClassCode + "WHERE " + "val.ValueContainerId = " + Long.toString(ValueContainerId) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); while (resultSet.next()) { classCode = resultSet.getString(1); classCodeList.add(classCode); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } ArrayList<MSSBamBoolDefBuff> resultList = new ArrayList<MSSBamBoolDefBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("BLN")) { MSSBamBoolDefBuff[] subList = readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLN")) { MSSBamTableBoolBuff[] subList = schema.getTableTableBool().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLN")) { MSSBamSchemaBoolBuff[] subList = schema.getTableSchemaBool().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } } return (resultList.toArray(new MSSBamBoolDefBuff[0])); }
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 a2 s . co m return ResultSet.CONCUR_READ_ONLY; }
From source file:com.github.podd.example.ExamplePoddClient.java
/** * Inserts the given line into the TrayScan database. * /* www.ja v a2s.c o m*/ * @param nextLine * @throws SQLException * @throws PoddClientException */ private void insertTrayScanToMySQL(final ExampleCSVLine nextLine) throws SQLException, PoddClientException { this.checkTrayScanServerDetails(); try (final Connection connection = this.getMySQLConnection();) { connection.setAutoCommit(false); final String trayQueryString = "SELECT * FROM tab_tray WHERE tray_textId = ?;"; try (final PreparedStatement prepareStatement = connection.prepareStatement(trayQueryString, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);) { prepareStatement.setString(1, nextLine.trayID); try (final ResultSet resultSet = prepareStatement.executeQuery()) { // If the tray did not exist, then store it if (!resultSet.next()) { final ResultSetMetaData metaData = resultSet.getMetaData(); try (final CallableStatement cs = connection.prepareCall("{call StoreTray(?, ?, ?)}");) { cs.setString(1, nextLine.trayID); cs.setString(2, nextLine.trayTypeName); cs.setString(3, nextLine.trayNotes); try (final ResultSet updateSet = cs.executeQuery();) { // TODO: Check to make sure call succeeded } } } } } final String plantQueryString = "SELECT * FROM tab_plant WHERE plant_textId = ?;"; try (final PreparedStatement prepareStatement = connection.prepareStatement(plantQueryString, ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY);) { prepareStatement.setString(1, nextLine.plantID); try (final ResultSet resultSet = prepareStatement.executeQuery()) { // If the plant did not exist, then store it if (!resultSet.next()) { final ResultSetMetaData metaData = resultSet.getMetaData(); try (final CallableStatement cs = connection .prepareCall("{call StorePlant(?, ?, ?, ?)}");) { cs.setString(1, nextLine.plantID); cs.setString(2, nextLine.potType); cs.setString(3, nextLine.plantName); cs.setString(4, nextLine.plantNotes); try (final ResultSet updateSet = cs.executeQuery();) { // TODO: Check to make sure call succeeded } } // If the plant did not already exist, also link it to its tray // TODO: Check for current assignments and call this if necessary try (final CallableStatement cs = connection.prepareCall("{call StoreAssign(?, ?, ?)}");) { cs.setString(1, nextLine.trayID); cs.setString(2, nextLine.plantID); cs.setString(3, nextLine.position); try (final ResultSet updateSet = cs.executeQuery();) { // TODO: Check to make sure call succeeded } } } } } connection.commit(); } }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BlobDefTable.java
public MSSBamBlobDefBuff[] readDerivedByVContIdx(MSSBamAuthorization Authorization, long ValueContainerId) { final String S_ProcName = "readDerivedByVContIdx"; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); }/* w w w . j a v a2s . co m*/ ArrayList<String> classCodeList = new ArrayList<String>(); String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectBlobDefDistinctClassCode + "WHERE " + "val.ValueContainerId = " + Long.toString(ValueContainerId) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); while (resultSet.next()) { classCode = resultSet.getString(1); classCodeList.add(classCode); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } ArrayList<MSSBamBlobDefBuff> resultList = new ArrayList<MSSBamBlobDefBuff>(); ListIterator<String> classCodeIter = classCodeList.listIterator(); while (classCodeIter.hasNext()) { classCode = classCodeIter.next(); if (classCode.equals("BLB")) { MSSBamBlobDefBuff[] subList = readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("TBLB")) { MSSBamTableBlobBuff[] subList = schema.getTableTableBlob().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else if (classCode.equals("SBLB")) { MSSBamSchemaBlobBuff[] subList = schema.getTableSchemaBlob().readBuffByVContIdx(Authorization, ValueContainerId); for (int subListIdx = 0; subListIdx < subList.length; subListIdx++) { resultList.add(subList[subListIdx]); } } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } } return (resultList.toArray(new MSSBamBlobDefBuff[0])); }
From source file:edu.ku.brc.specify.conversion.BasicSQLUtils.java
/** * Deletes all the records from a table/*from w w w . j a va2 s .c o m*/ * @param connection connection to the DB * @param tableName the name of the table * @return the return value from the SQL update statement (or -1 on an exception) */ public static int deleteAllRecordsFromTable(final Connection connection, final String tableName, final SERVERTYPE currentServerType) { try { if (doesTableExist(connection, tableName)) { Integer count = getCount(connection, "SELECT COUNT(*) FROM " + tableName); if (count == null || count == 0) { return 0; } Statement stmt = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); if (currentServerType != SERVERTYPE.MS_SQLServer) { removeForeignKeyConstraints(stmt.getConnection(), currentServerType); } int retVal = exeUpdateCmd(stmt, "delete from " + tableName); stmt.clearBatch(); stmt.close(); log.info("Deleted " + count + " records from " + tableName); return retVal; } } catch (SQLException ex) { edu.ku.brc.af.core.UsageTracker.incrSQLUsageCount(); edu.ku.brc.exceptions.ExceptionTracker.getInstance().capture(BasicSQLUtils.class, ex); log.error(ex); ex.printStackTrace(); } return 0; }
From source file:net.sourceforge.msscodefactory.v1_10.MSSBamPg8.MSSBamPg8BaseDomainTable.java
public MSSBamBaseDomainBuff readDerivedByUNameIdx(MSSBamAuthorization Authorization, Long ScopeId, String Name) {/*from w ww . j av a 2s. c o m*/ final String S_ProcName = "MSSBamPg8BaseDomainTable.readDerivedByUNameIdx() "; MSSBamBaseDomainBuff buff; if (!schema.isTransactionOpen()) { throw CFLib.getDefaultExceptionFactory().newUsageException(getClass(), S_ProcName, "Transaction not open"); } String classCode; try { Connection cnx = schema.getCnx(); String sql = S_sqlSelectBaseDomainDistinctClassCode + "WHERE " + ((ScopeId == null) ? "anyo.ScopeId is null " : "anyo.ScopeId = " + ScopeId.toString() + " ") + "AND " + "anyo.Name = " + MSSBamPg8Schema.getQuotedString(Name) + " "; Statement stmt = cnx.createStatement(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY); ResultSet resultSet = stmt.executeQuery(sql); if (resultSet.next()) { classCode = resultSet.getString(1); if (resultSet.next()) { resultSet.last(); throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect multi-buff response, " + resultSet.getRow() + " rows selected"); } } else { return (null); } } catch (SQLException e) { throw CFLib.getDefaultExceptionFactory().newDbException(getClass(), S_ProcName, e); } if (classCode.equals("BDM")) { buff = readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("DOM")) { buff = schema.getTableDomain().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("LENT")) { buff = schema.getTableLegalEntity().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("COM")) { buff = schema.getTableCompany().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("USR")) { buff = schema.getTableUser().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("PRJ")) { buff = schema.getTableProject().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("VER")) { buff = schema.getTableVersion().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("MJV")) { buff = schema.getTableMajorVersion().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("MNV")) { buff = schema.getTableMinorVersion().readBuffByUNameIdx(Authorization, ScopeId, Name); } else if (classCode.equals("TLD")) { buff = schema.getTableTLD().readBuffByUNameIdx(Authorization, ScopeId, Name); } else { throw CFLib.getDefaultExceptionFactory().newRuntimeException(getClass(), S_ProcName, "Did not expect ClassCode \"" + classCode + "\""); } return (buff); }