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:SyncMusicServlet.java
private void processAlbumData(String name, String artist, String composer, String year) { Connection conn = null;// ww w . j a 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); String sql = "select * from album where album_title='" + name + "'"; rs = stmt.executeQuery(sql); rs.next(); if (rs.getRow() == 0) { pstmt = conn.prepareStatement( "insert into album (album_title, album_artist, album_composer, release_year) values (?, ?, ?, ?)"); pstmt.setString(1, name); pstmt.setString(2, artist); pstmt.setString(3, composer); pstmt.setString(4, year); pstmt.executeUpdate(); } //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:com.alibaba.wasp.jdbc.TestJdbcStatement.java
@Test public void testStatement() throws SQLException, IOException, InterruptedException { Statement stat = conn.createStatement(); assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, conn.getHoldability()); conn.setHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT); assertEquals(ResultSet.CLOSE_CURSORS_AT_COMMIT, conn.getHoldability()); // ignored//w w w. ja v a2 s. com stat.setCursorName("x"); // fixed return value assertEquals(stat.getFetchDirection(), ResultSet.FETCH_FORWARD); // ignored stat.setFetchDirection(ResultSet.FETCH_REVERSE); // ignored stat.setMaxFieldSize(100); assertEquals(conf.getInt(FConstants.WASP_JDBC_FETCHSIZE, FConstants.DEFAULT_WASP_JDBC_FETCHSIZE), stat.getFetchSize()); stat.setFetchSize(10); assertEquals(10, stat.getFetchSize()); stat.setFetchSize(0); assertEquals(conf.getInt(FConstants.WASP_JDBC_FETCHSIZE, FConstants.DEFAULT_WASP_JDBC_FETCHSIZE), stat.getFetchSize()); assertEquals(ResultSet.TYPE_FORWARD_ONLY, stat.getResultSetType()); Statement stat2 = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY, ResultSet.HOLD_CURSORS_OVER_COMMIT); assertEquals(ResultSet.TYPE_SCROLL_SENSITIVE, stat2.getResultSetType()); assertEquals(ResultSet.HOLD_CURSORS_OVER_COMMIT, stat2.getResultSetHoldability()); assertEquals(ResultSet.CONCUR_READ_ONLY, stat2.getResultSetConcurrency()); assertEquals(0, stat.getMaxFieldSize()); assertTrue(!((JdbcStatement) stat2).isClosed()); stat2.close(); assertTrue(((JdbcStatement) stat2).isClosed()); ResultSet rs; int count; boolean result; stat.execute("CREATE TABLE TEST {REQUIRED INT64 ID;" + "REQUIRED STRING VALUE; }PRIMARY KEY(ID), " + "ENTITY GROUP ROOT,ENTITY GROUP KEY(ID);"); TEST_UTIL.waitTableEnabled(Bytes.toBytes("TEST"), 5000); ResultInHBasePrinter.printMETA(conf, LOG); ResultInHBasePrinter.printFMETA(conf, LOG); ResultInHBasePrinter.printTable("test", "WASP_ENTITY_TEST", conf, LOG); conn.getTypeMap(); // this method should not throw an exception - if not supported, this // calls are ignored assertEquals(ResultSet.CONCUR_READ_ONLY, stat.getResultSetConcurrency()); // stat.cancel(); stat.setQueryTimeout(10); assertTrue(stat.getQueryTimeout() == 10); stat.setQueryTimeout(0); assertTrue(stat.getQueryTimeout() == 0); // assertThrows(SQLErrorCode.INVALID_VALUE_2, stat).setQueryTimeout(-1); assertTrue(stat.getQueryTimeout() == 0); trace("executeUpdate"); count = stat.executeUpdate("INSERT INTO TEST (ID,VALUE) VALUES (1,'Hello')"); assertEquals(1, count); count = stat.executeUpdate("INSERT INTO TEST (VALUE,ID) VALUES ('JDBC',2)"); assertEquals(1, count); count = stat.executeUpdate("UPDATE TEST SET VALUE='LDBC' WHERE ID=1"); assertEquals(1, count); count = stat.executeUpdate("DELETE FROM TEST WHERE ID=-1"); assertEquals(0, count); count = stat.executeUpdate("DELETE FROM TEST WHERE ID=1"); assertEquals(1, count); count = stat.executeUpdate("DELETE FROM TEST WHERE ID=2"); assertEquals(1, count); result = stat.execute("INSERT INTO TEST(ID,VALUE) VALUES(1,'Hello')"); assertTrue(!result); result = stat.execute("INSERT INTO TEST(VALUE,ID) VALUES('JDBC',2)"); assertTrue(!result); result = stat.execute("UPDATE TEST SET VALUE='LDBC' WHERE ID=2"); assertTrue(!result); result = stat.execute("DELETE FROM TEST WHERE ID=1"); assertTrue(!result); result = stat.execute("DELETE FROM TEST WHERE ID=2"); assertTrue(!result); result = stat.execute("DELETE FROM TEST WHERE ID=3"); assertTrue(!result); // getMoreResults rs = stat.executeQuery("SELECT ID,VALUE FROM TEST WHERE ID=1"); assertFalse(stat.getMoreResults()); assertThrows(SQLErrorCode.OBJECT_CLOSED, rs).next(); assertTrue(stat.getUpdateCount() == -1); count = stat.executeUpdate("DELETE FROM TEST WHERE ID=1"); assertFalse(stat.getMoreResults()); assertTrue(stat.getUpdateCount() == -1); WaspAdmin admin = new WaspAdmin(TEST_UTIL.getConfiguration()); admin.disableTable("TEST"); stat.execute("DROP TABLE TEST"); admin.waitTableNotLocked("TEST".getBytes()); stat.executeUpdate("DROP TABLE IF EXISTS TEST"); assertTrue(stat.getWarnings() == null); stat.clearWarnings(); assertTrue(stat.getWarnings() == null); assertTrue(conn == stat.getConnection()); admin.close(); stat.close(); }
From source file:solarrecorder.SolarRecorder.java
private void sendSolarUpdate() { String dbString = "jdbc:mysql://localhost:3306/Solar"; try {//from w w w. j a v a 2 s . c o m Connection con = DriverManager.getConnection(dbString, "colin", "Quackquack1"); Statement stmt = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); String SQL = "SELECT * FROM Production"; ResultSet rs = stmt.executeQuery(SQL); rs.moveToInsertRow(); getData(); java.util.Date now = new java.util.Date(); rs.updateDate("Day", new Date(now.getTime())); rs.updateTime("Time", new Time(now.getTime())); for (Object evp : envoyData) { switch (((EnvoyData) evp).getName()) { case "Currently": rs.updateDouble("Current", extractCurrent(((EnvoyData) evp).getValue())); break; case "Today": rs.updateDouble("Today", extractToday(((EnvoyData) evp).getValue())); break; case "Number of Microinverters Online": rs.updateInt("Inverters", Integer.parseInt(((EnvoyData) evp).getValue())); break; } } rs.insertRow(); stmt.close(); rs.close(); } catch (Exception ex) { ex.printStackTrace(); } }
From source file:org.opennms.model.utils.AssetsUpdater.java
protected static void parseCsv2(final File csv) throws ClassNotFoundException, SQLException, IOException { String sql = m_dbQuery;/* w w w. java 2 s. c om*/ Connection con = createConnection(false); PreparedStatement ps = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(csv))); CSVReader csvReader = new CSVReader(br); String[] line; int lineCnt = 0; while ((line = csvReader.readNext()) != null) { System.out.println("Processing csv line: " + String.valueOf(++lineCnt)); if (line.length != m_fieldMap.size() + 1) { continue; } String foreignSource = m_formatter.formatForeignSource(StringUtils.isBlank(line[0]) ? null : line[0]); System.out.println("Running query for foreignSource: " + foreignSource + " ..."); ps.setString(1, foreignSource); ResultSet rs = ps.executeQuery(); rs.last(); int rows = rs.getRow(); if (rows < 1) { rs.close(); System.out.println("No results found for foreignsource: " + foreignSource + "; continuing to next foreignsource..."); continue; } System.out.println("Found " + rows + " rows."); rs.beforeFirst(); while (rs.next()) { System.out.println("Updating node: " + rs.getInt("nodeid")); Set<Entry<Integer, String>> entrySet = m_fieldMap.entrySet(); for (Entry<Integer, String> entry : entrySet) { int csvField = entry.getKey() - 1; String columnName = entry.getValue(); System.out.println( "\t" + "updating column: " + columnName + " with csv field: " + line[csvField]); rs.updateString(columnName, line[csvField]); } rs.updateRow(); } rs.close(); } try { con.commit(); } catch (SQLException e) { e.printStackTrace(); con.rollback(); } csvReader.close(); ps.close(); con.close(); }
From source file:com.github.adejanovski.cassandra.jdbc.CassandraStatement.java
CassandraStatement(CassandraConnection con, String cql, int resultSetType, int resultSetConcurrency, int resultSetHoldability) throws SQLException { this.connection = con; this.cql = cql; this.batchQueries = Lists.newArrayList(); this.consistencyLevel = con.defaultConsistencyLevel; if (!(resultSetType == ResultSet.TYPE_FORWARD_ONLY || resultSetType == ResultSet.TYPE_SCROLL_INSENSITIVE || resultSetType == ResultSet.TYPE_SCROLL_SENSITIVE)) throw new SQLSyntaxErrorException(BAD_TYPE_RSET); this.resultSetType = resultSetType; if (!(resultSetConcurrency == ResultSet.CONCUR_READ_ONLY || resultSetConcurrency == ResultSet.CONCUR_UPDATABLE)) throw new SQLSyntaxErrorException(BAD_TYPE_RSET); this.resultSetConcurrency = resultSetConcurrency; if (!(resultSetHoldability == ResultSet.HOLD_CURSORS_OVER_COMMIT || resultSetHoldability == ResultSet.CLOSE_CURSORS_AT_COMMIT)) throw new SQLSyntaxErrorException(BAD_HOLD_RSET); this.resultSetHoldability = resultSetHoldability; }
From source file:recite18th.library.Db.java
public static boolean executeQuery(String sql) { try {/*from w w w . j a va2 s . c o m*/ Statement statement = getCon().createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY); Logger.getLogger(Db.class.getName()).log(Level.SEVERE, "executeQuery : {0}", sql); statement.execute(sql); return true; } catch (SQLException ex) { Logger.getLogger(Db.class.getName()).log(Level.SEVERE, null, ex); return false; } }
From source file:UserPerformance.GetLowerBound.java
public double getUpperB(String GetFixedJobIds) { //get mean from db double Mean_TimePerItem = 0; try {// w w w . j a va2 s . com ResultSet reset; Statement stmt; String query; query = "SELECT AVG(TIME_PER_ONE_ITEM)\n" + " FROM dbo.UsersVsCompleteItems\n" + " WHERE JobFinished_FIXED_JOB_ID = '" + GetFixedJobIds + "'"; stmt = ConnectSql.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); reset = stmt.executeQuery(query); if (reset.next()) { String wd = reset.getString(1); Mean_TimePerItem = Double.parseDouble(wd); } reset.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Please contact for support."); } //get item Count from db double n_Count = 0; try { ResultSet reset; Statement stmt; String query; query = "SELECT COUNT(TIME_PER_ONE_ITEM)\n" + " FROM dbo.UsersVsCompleteItems\n" + " WHERE JobFinished_FIXED_JOB_ID = '" + GetFixedJobIds + "'"; stmt = ConnectSql.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); reset = stmt.executeQuery(query); if (reset.next()) { String wd = reset.getString(1); n_Count = Double.parseDouble(wd); } reset.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Please contact for support."); } //get item Standed deviation from db double st_Dev = 0; try { ResultSet reset; Statement stmt; String query; query = "SELECT STDEV(TIME_PER_ONE_ITEM)\n" + " FROM dbo.UsersVsCompleteItems\n" + " WHERE JobFinished_FIXED_JOB_ID = '" + GetFixedJobIds + "'"; stmt = ConnectSql.conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); reset = stmt.executeQuery(query); if (reset.next()) { st_Dev = reset.getDouble(1); } reset.close(); } catch (SQLException ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); JOptionPane.showMessageDialog(null, "Please contact for support."); } //get alfa Double alfa = 0.9; System.out.println("Confidence Interval for Fixed Job : " + alfa * 100 + "%"); // Calculate 90% confidence interval double S_Mean_TimePerItem = roundTwoDecimals(Mean_TimePerItem); double ci = calcMeanCI(n_Count, st_Dev, alfa); System.out.println("Mean for Fixed Job : " + S_Mean_TimePerItem); double S_lower = (Mean_TimePerItem - ci); double lower = roundTwoDecimals(S_lower); double S_upper = (Mean_TimePerItem + ci); double upper = roundTwoDecimals(S_upper); System.out.println("Upper Limit for Fixed Job : " + upper); return upper; }
From source file:org.acmsl.queryj.tools.handlers.DatabaseMetaDataLoggingHandler.java
/** * Handles given information./*ww w . j ava 2s.c o m*/ * @param metaData the database metadata. * @return <code>true</code> if the chain should be stopped. * @throws QueryJBuildException if the metadata cannot be logged. */ protected boolean handle(@NotNull final DatabaseMetaData metaData) throws QueryJBuildException { final boolean result = false; @Nullable Log t_Log = null; try { t_Log = UniqueLogFactory.getLog(DatabaseMetaDataLoggingHandler.class); if (t_Log != null) { t_Log.debug("Numeric functions:" + metaData.getNumericFunctions()); t_Log.debug("String functions:" + metaData.getStringFunctions()); t_Log.debug("System functions:" + metaData.getSystemFunctions()); t_Log.debug("Time functions:" + metaData.getTimeDateFunctions()); t_Log.debug("insertsAreDetected(TYPE_FORWARD_ONLY):" + metaData.insertsAreDetected(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("insertsAreDetected(TYPE_SCROLL_INSENSITIVE):" + metaData.insertsAreDetected(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("insertsAreDetected(TYPE_SCROLL_SENS):" + metaData.insertsAreDetected(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("isCatalogAtStart():" + metaData.isCatalogAtStart()); t_Log.debug("isReadOnly():" + metaData.isReadOnly()); /* * Fails for MySQL with a java.lang.AbstractMethodError * com.mysql.jdbc.jdbc2.DatabaseMetaData.locatorsUpdateCopy() t_Log.debug( "locatorsUpdateCopy():" + metaData.locatorsUpdateCopy()); */ t_Log.debug("nullPlusNonNullIsNull():" + metaData.nullPlusNonNullIsNull()); t_Log.debug("nullsAreSortedAtEnd():" + metaData.nullsAreSortedAtEnd()); t_Log.debug("nullsAreSortedAtStart():" + metaData.nullsAreSortedAtStart()); t_Log.debug("nullsAreSortedHigh():" + metaData.nullsAreSortedHigh()); t_Log.debug("nullsAreSortedLow():" + metaData.nullsAreSortedLow()); t_Log.debug("othersDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY):" + metaData.othersDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("othersDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE):" + metaData.othersDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("othersDeletesAreVisible(ResultSet.TYPE_SCROLL_SENS):" + metaData.othersDeletesAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("othersInsertsAreVisible(ResultSet.TYPE_FORWARD_ONLY):" + metaData.othersInsertsAreVisible(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("othersInsertsAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE):" + metaData.othersInsertsAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("othersInsertsAreVisible(ResultSet.TYPE_SCROLL_SENS):" + metaData.othersInsertsAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("othersUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY):" + metaData.othersUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("othersUpdatesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE):" + metaData.othersUpdatesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("othersUpdatesAreVisible(ResultSet.TYPE_SCROLL_SENS):" + metaData.othersUpdatesAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("ownDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY):" + metaData.ownDeletesAreVisible(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("ownDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE):" + metaData.ownDeletesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("ownDeletesAreVisible(ResultSet.TYPE_SCROLL_SENS):" + metaData.ownDeletesAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("ownInsertsAreVisible(ResultSet.TYPE_FORWARD_ONLY):" + metaData.ownInsertsAreVisible(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("ownInsertsAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE):" + metaData.ownInsertsAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("ownInsertsAreVisible(ResultSet.TYPE_SCROLL_SENS):" + metaData.ownInsertsAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("ownUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY):" + metaData.ownUpdatesAreVisible(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("ownUpdatesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE):" + metaData.ownUpdatesAreVisible(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("ownUpdatesAreVisible(ResultSet.TYPE_SCROLL_SENS):" + metaData.ownUpdatesAreVisible(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("storesLowerCaseIdentifiers():" + metaData.storesLowerCaseIdentifiers()); t_Log.debug("storesLowerCaseQuotedIdentifiers():" + metaData.storesLowerCaseQuotedIdentifiers()); t_Log.debug("storesMixedCaseIdentifiers():" + metaData.storesMixedCaseIdentifiers()); t_Log.debug("storesMixedCaseQuotedIdentifiers():" + metaData.storesMixedCaseQuotedIdentifiers()); t_Log.debug("storesUpperCaseIdentifiers():" + metaData.storesUpperCaseIdentifiers()); t_Log.debug("storesUpperCaseQuotedIdentifiers():" + metaData.storesUpperCaseQuotedIdentifiers()); t_Log.debug("supportsAlterTableWithAddColumn():" + metaData.supportsAlterTableWithAddColumn()); t_Log.debug("supportsAlterTableWithDropColumn():" + metaData.supportsAlterTableWithDropColumn()); t_Log.debug("supportsANSI92EntryLevelSQL():" + metaData.supportsANSI92EntryLevelSQL()); t_Log.debug("supportsANSI92FullSQL():" + metaData.supportsANSI92FullSQL()); t_Log.debug("supportsANSI92IntermediateSQL():" + metaData.supportsANSI92IntermediateSQL()); t_Log.debug("supportsBatchUpdates():" + metaData.supportsBatchUpdates()); t_Log.debug( "supportsCatalogsInDataManipulation():" + metaData.supportsCatalogsInDataManipulation()); t_Log.debug( "supportsCatalogsInIndexDefinitions():" + metaData.supportsCatalogsInIndexDefinitions()); t_Log.debug("supportsCatalogsInPrivilegeDefinitions():" + metaData.supportsCatalogsInPrivilegeDefinitions()); t_Log.debug("supportsCatalogsInProcedureCalls():" + metaData.supportsCatalogsInProcedureCalls()); t_Log.debug( "supportsCatalogsInTableDefinitions():" + metaData.supportsCatalogsInTableDefinitions()); t_Log.debug("supportsColumnAliasing():" + metaData.supportsColumnAliasing()); t_Log.debug("supportsConvert():" + metaData.supportsConvert()); t_Log.debug("supportsCoreSQLGrammar():" + metaData.supportsCoreSQLGrammar()); t_Log.debug("supportsCorrelatedSubqueries():" + metaData.supportsCorrelatedSubqueries()); t_Log.debug("supportsDataDefinitionAndDataManipulationTransactions():" + metaData.supportsDataDefinitionAndDataManipulationTransactions()); t_Log.debug("supportsDataManipulationTransactionsOnly():" + metaData.supportsDataManipulationTransactionsOnly()); t_Log.debug("supportsDifferentTableCorrelationNames():" + metaData.supportsDifferentTableCorrelationNames()); t_Log.debug("supportsExpressionsInOrderBy():" + metaData.supportsExpressionsInOrderBy()); t_Log.debug("supportsExtendedSQLGrammar():" + metaData.supportsExtendedSQLGrammar()); t_Log.debug("supportsFullOuterJoins():" + metaData.supportsFullOuterJoins()); String t_strSupportsGetGeneratedKeys = Boolean.FALSE.toString(); try { t_strSupportsGetGeneratedKeys = "" + metaData.supportsGetGeneratedKeys(); } catch (@NotNull final SQLException sqlException) { t_strSupportsGetGeneratedKeys += sqlException.getMessage(); } t_Log.debug("supportsGetGeneratedKeys():" + t_strSupportsGetGeneratedKeys); t_Log.debug("supportsGroupBy():" + metaData.supportsGroupBy()); t_Log.debug("supportsGroupByBeyondSelect():" + metaData.supportsGroupByBeyondSelect()); t_Log.debug("supportsGroupByUnrelated():" + metaData.supportsGroupByUnrelated()); t_Log.debug("supportsIntegrityEnhancementFacility():" + metaData.supportsIntegrityEnhancementFacility()); t_Log.debug("supportsLikeEscapeClause():" + metaData.supportsLikeEscapeClause()); t_Log.debug("supportsLimitedOuterJoins():" + metaData.supportsLimitedOuterJoins()); t_Log.debug("supportsMinimumSQLGrammar():" + metaData.supportsMinimumSQLGrammar()); t_Log.debug("supportsMixedCaseIdentifiers():" + metaData.supportsMixedCaseIdentifiers()); t_Log.debug( "supportsMixedCaseQuotedIdentifiers():" + metaData.supportsMixedCaseQuotedIdentifiers()); /* * Fails in MySQL 3.23.53 with a java.lang.AbstractMethodError * com.mysql.jdbc.jdbc2.DatabaseMetaData.supportsMultipleOpenResults() t_Log.debug( "supportsMultipleOpenResults():" + metaData.supportsMultipleOpenResults()); */ t_Log.debug("supportsMultipleResultSets():" + metaData.supportsMultipleResultSets()); t_Log.debug("supportsMultipleTransactions():" + metaData.supportsMultipleTransactions()); /* * Fails in MySQL 3.23.53 with a java.lang.AbstractMethodError * com.mysql.jdbc.jdbc2.DatabaseMetaData.supportsNamedParameters() t_Log.debug( "supportsNamedParameters():" + metaData.supportsNamedParameters()); */ t_Log.debug("supportsNonNullableColumns():" + metaData.supportsNonNullableColumns()); t_Log.debug("supportsOpenCursorsAcrossCommit():" + metaData.supportsOpenCursorsAcrossCommit()); t_Log.debug("supportsOpenCursorsAcrossRollback():" + metaData.supportsOpenCursorsAcrossRollback()); t_Log.debug( "supportsOpenStatementsAcrossCommit():" + metaData.supportsOpenStatementsAcrossCommit()); t_Log.debug("supportsOpenStatementsAcrossRollback():" + metaData.supportsOpenStatementsAcrossRollback()); t_Log.debug("supportsOrderByUnrelated():" + metaData.supportsOrderByUnrelated()); t_Log.debug("supportsOuterJoins():" + metaData.supportsOuterJoins()); t_Log.debug("supportsPositionedDelete():" + metaData.supportsPositionedDelete()); t_Log.debug("supportsPositionedUpdate():" + metaData.supportsPositionedUpdate()); t_Log.debug("supportsResultSetConcurrency(TYPE_FORWARD_ONLY,CONCUR_READ_ONLY):" + metaData .supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_READ_ONLY)); t_Log.debug("supportsResultSetConcurrency(TYPE_FORWARD_ONLY,CONCUR_UPDATABLE):" + metaData .supportsResultSetConcurrency(ResultSet.TYPE_FORWARD_ONLY, ResultSet.CONCUR_UPDATABLE)); t_Log.debug("supportsResultSetConcurrency(TYPE_SCROLL_INSENSITIVE,CONCUR_READ_ONLY):" + metaData.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY)); t_Log.debug("supportsResultSetConcurrency(TYPE_SCROLL_INSENSITIVE,CONCUR_UPDATABLE):" + metaData.supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE)); t_Log.debug("supportsResultSetConcurrency(TYPE_SCROLL_SENSITIVE,CONCUR_READ_ONLY):" + metaData .supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_READ_ONLY)); t_Log.debug("supportsResultSetConcurrency(TYPE_SCROLL_SENSITIVE,CONCUR_UPDATABLE):" + metaData .supportsResultSetConcurrency(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE)); /* * Fails in MySQL 3.23.53 with a java.lang.AbstractMethodError * com.mysql.jdbc.jdbc2.DatabaseMetaData.supportsResultSetHoldability() t_Log.debug( "supportsResultSetHoldability(" + "HOLD_CURSORS_OVER_COMMIT):" + metaData.supportsResultSetHoldability( ResultSet.HOLD_CURSORS_OVER_COMMIT)); t_Log.debug( "supportsResultSetHoldability(" + "CLOSE_CURSORS_AT_COMMIT):" + metaData.supportsResultSetHoldability( ResultSet.CLOSE_CURSORS_AT_COMMIT)); */ t_Log.debug("supportsResultSetType(TYPE_FORWARD_ONLY):" + metaData.supportsResultSetType(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE):" + metaData.supportsResultSetType(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("supportsResultSetType(TYPE_SCROLL_SENSITIVE):" + metaData.supportsResultSetType(ResultSet.TYPE_SCROLL_SENSITIVE)); /* * Fails in MySQL 3.23.53 with a java.lang.AbstractMethodError * com.mysql.jdbc.jdbc2.DatabaseMetaData.supportsSavePoints() t_Log.debug( "supportsSavepoints():" + metaData.supportsSavepoints()); */ t_Log.debug("supportsSchemasInDataManipulation():" + metaData.supportsSchemasInDataManipulation()); t_Log.debug("supportsSchemasInIndexDefinitions():" + metaData.supportsSchemasInIndexDefinitions()); t_Log.debug("supportsSchemasInPrivilegeDefinitions():" + metaData.supportsSchemasInPrivilegeDefinitions()); t_Log.debug("supportsSchemasInProcedureCalls():" + metaData.supportsSchemasInProcedureCalls()); t_Log.debug("supportsSchemasInTableDefinitions():" + metaData.supportsSchemasInTableDefinitions()); t_Log.debug("supportsSelectForUpdate():" + metaData.supportsSelectForUpdate()); /* * Fails in MySQL 3.23.53 with a java.lang.AbstractMethodError * com.mysql.jdbc.jdbc2.DatabaseMetaData.supportsStatementPooling() t_Log.debug( "supportsStatementPooling():" + metaData.supportsStatementPooling()); */ t_Log.debug("supportsStoredProcedures():" + metaData.supportsStoredProcedures()); t_Log.debug("supportsSubqueriesInComparisons():" + metaData.supportsSubqueriesInComparisons()); t_Log.debug("supportsSubqueriesInExists():" + metaData.supportsSubqueriesInExists()); t_Log.debug("supportsSubqueriesInIns():" + metaData.supportsSubqueriesInIns()); t_Log.debug("supportsSubqueriesInQuantifieds():" + metaData.supportsSubqueriesInQuantifieds()); t_Log.debug("supportsTableCorrelationNames():" + metaData.supportsTableCorrelationNames()); t_Log.debug("supportsTransactionIsolationLevel(TRANSACTION_NONE):" + metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_NONE)); t_Log.debug("supportsTransactionIsolationLevel(TRANSACTION_READ_COMMITTED):" + metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_COMMITTED)); t_Log.debug("supportsTransactionIsolationLevel(TRANSACTION_READ_UNCOMMITTED):" + metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_READ_UNCOMMITTED)); t_Log.debug("supportsTransactionIsolationLevel(TRANSACTION_REPEATABLE_READ):" + metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_REPEATABLE_READ)); t_Log.debug("supportsTransactionIsolationLevel(TRANSACTION_SERIALIZABLE):" + metaData.supportsTransactionIsolationLevel(Connection.TRANSACTION_SERIALIZABLE)); t_Log.debug("supportsTransactions():" + metaData.supportsTransactions()); t_Log.debug("supportsUnion():" + metaData.supportsUnion()); t_Log.debug("supportsUnionAll():" + metaData.supportsUnionAll()); t_Log.debug("updatesAreDetected(TYPE_FORWARD_ONLY):" + metaData.updatesAreDetected(ResultSet.TYPE_FORWARD_ONLY)); t_Log.debug("updatesAreDetected(TYPE_SCROLL_INSENSITIVE):" + metaData.updatesAreDetected(ResultSet.TYPE_SCROLL_INSENSITIVE)); t_Log.debug("updatesAreDetected(" + "TYPE_SCROLL_SENS):" + metaData.updatesAreDetected(ResultSet.TYPE_SCROLL_SENSITIVE)); t_Log.debug("usesLocalFilePerTable():" + metaData.usesLocalFilePerTable()); t_Log.debug("usesLocalFiles():" + metaData.usesLocalFiles()); } } catch (@NotNull final SQLException sqlException) { t_Log.error("Database metadata request failed.", sqlException); } return result; }
From source file:org.biblionum.ouvrage.modele.OuvrageModele.java
/** * Java method that updates a row in the generated sql table * * @param con (open java.sql.Connection) * @param auteur/*from w w w.j a va 2 s . c o m*/ * @param editeur * @param annee_edition * @param resume * @param nb_page * @param emplacement * @param couverture * @param ouvrageTipeid * @param categorieOuvrageid * @param niveauid_niveau * @param filiereid * @param titre * @return boolean (true on success) * @throws SQLException */ public boolean updateUtilisateur(DataSource ds, int keyId, String auteur, String editeur, int annee_edition, String resume, int nb_page, String emplacement, String couverture, int ouvrageTipeid, int categorieOuvrageid, int niveauid_niveau, int filiereid, String titre) throws SQLException { con = ds.getConnection(); String sql = "SELECT * FROM ouvrage WHERE id = ?"; PreparedStatement statement = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); statement.setInt(1, keyId); ResultSet entry = statement.executeQuery(); entry.last(); int rows = entry.getRow(); entry.beforeFirst(); if (rows == 0) { entry.close(); statement.close(); con.close(); return false; } entry.next(); if (auteur != null) { entry.updateString("auteur", auteur); } if (editeur != null) { entry.updateString("editeur", editeur); } entry.updateInt("annee_edition", annee_edition); if (resume != null) { entry.updateString("resume", resume); } entry.updateInt("nb_page", nb_page); if (emplacement != null) { entry.updateString("emplacement", emplacement); } if (couverture != null) { entry.updateString("couverture", couverture); } entry.updateInt("ouvrageTipeid", ouvrageTipeid); entry.updateInt("categorieOuvrageid", categorieOuvrageid); entry.updateInt("niveauid_niveau", niveauid_niveau); entry.updateInt("filiereid", filiereid); if (titre != null) { entry.updateString("titre", titre); } entry.updateRow(); entry.close(); statement.close(); con.close(); return true; }
From source file:org.apache.ambari.server.checks.CheckDatabaseHelper.java
protected void checkForNotMappedConfigsToCluster() { String GET_NOT_MAPPED_CONFIGS_QUERY = "select type_name from clusterconfig where type_name not in (select type_name from clusterconfigmapping)"; Set<String> nonSelectedConfigs = new HashSet<>(); ResultSet rs = null;/* w w w . ja v a 2 s.c om*/ try { Statement statement = connection.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); rs = statement.executeQuery(GET_NOT_MAPPED_CONFIGS_QUERY); if (rs != null) { while (rs.next()) { nonSelectedConfigs.add(rs.getString("type_name")); } } if (!nonSelectedConfigs.isEmpty()) { LOG.warn( "You have config(s): {} that is(are) not mapped (in clusterconfigmapping table) to any cluster!", StringUtils.join(nonSelectedConfigs, ",")); warningAvailable = true; } } catch (SQLException e) { LOG.error("Exception occurred during check for not mapped configs to cluster procedure: ", e); } finally { if (rs != null) { try { rs.close(); } catch (SQLException e) { LOG.error("Exception occurred during result set closing procedure: ", e); } } } }