@Override public void setAutoCommit(boolean autoCommit) throws SQLException { // Per JDBC spec, if the connection is closed a SQLException should be thrown. if(isClosed) { throw new SQLException("Connection is closed"); } // The auto-commit mode is always enabled for this connection. Per JDBC spec, // if setAutoCommit is called and the auto-commit mode is not changed, the call is a no-op. if (!autoCommit) { LOG.warn("Request to set autoCommit to false; Hive does not support autoCommit=false."); SQLWarning warning = new SQLWarning("Hive does not support autoCommit=false"); if (warningChain == null) warningChain = warning; else warningChain.setNextWarning(warning); } }
private SQLWarning receiveNotification() throws IOException { String warnMsg = pgStream.ReceiveString(); // Strip out the severity field so we have consistency with // the V3 protocol. SQLWarning.getMessage should return just // the actual message. // int severityMark = warnMsg.indexOf(":"); warnMsg = warnMsg.substring(severityMark+1).trim(); if (logger.logDebug()) logger.debug(" <=BE NoticeResponse(" + warnMsg + ")"); return new SQLWarning(warnMsg); }
private void updateQueryLog() { try { List<String> queryLogs = hiveStatement.getQueryLog(); for (String log : queryLogs) { if (!commands.beeLine.isTestMode()) { commands.beeLine.info(log); } else { // In test mode print the logs to the output commands.beeLine.output(log); } } if (!queryLogs.isEmpty()) { notifier.operationLogShowedToUser(); } } catch (SQLException e) { commands.error(new SQLWarning(e)); } }
addWarning(new SQLWarning(GT.tr("ClientInfo property not supported."), PSQLState.NOT_IMPLEMENTED.getState()));
private void showRemainingLogsIfAny(Statement statement) { if (statement instanceof HiveStatement) { HiveStatement hiveStatement = (HiveStatement) statement; List<String> logs = null; do { try { logs = hiveStatement.getQueryLog(); } catch (SQLException e) { beeLine.error(new SQLWarning(e)); return; } for (String log : logs) { if (!beeLine.isTestMode()) { beeLine.info(log); } else { // In test mode print the logs to the output beeLine.output(log); } } } while (logs.size() > 0); } else { beeLine.debug("The statement instance is not HiveStatement type: " + statement.getClass()); } }
@Test public void testIgnoredWarning() throws Exception { String sql = "SELECT forename from custmr"; SQLWarning warnings = new SQLWarning("My warning"); given(this.resultSet.next()).willReturn(false); given(this.connection.createStatement()).willReturn(this.preparedStatement); given(this.preparedStatement.getWarnings()).willReturn(warnings); // Too long: truncation this.template.setIgnoreWarnings(true); this.template.query(sql, rs -> { rs.getByte(1); }); verify(this.resultSet).close(); verify(this.preparedStatement).close(); verify(this.connection).close(); }
/** * Mock objects allow us to produce warnings at will */ @Test public void testFatalWarning() throws Exception { String sql = "SELECT forename from custmr"; SQLWarning warnings = new SQLWarning("My warning"); given(this.resultSet.next()).willReturn(false); given(this.preparedStatement.getWarnings()).willReturn(warnings); given(this.connection.createStatement()).willReturn(this.preparedStatement); JdbcTemplate t = new JdbcTemplate(this.dataSource); t.setIgnoreWarnings(false); this.thrown.expect(SQLWarningException.class); this.thrown.expect(exceptionCause(sameInstance(warnings))); try { t.query(sql, rs -> { rs.getByte(1); }); } finally { verify(this.resultSet).close(); verify(this.preparedStatement).close(); verify(this.connection).close(); } }
new SQLWarning(warn.getMessage(), warn.getSQLState(), warn.getErrorCode()); SQLWarning nw = warn.getNextWarning(); while ( nw != null ) tw.setNextWarning(new SQLWarning(nw.getMessage(), nw.getSQLState(), nw.getErrorCode())); new SQLWarning(warn.getMessage(), warn.getSQLState(), warn.getErrorCode()));
if (logger.logDebug()) logger.debug(" <=BE NoticeResponse(" + warnMsg + ")"); protoConnection.addWarning(new SQLWarning(warnMsg)); break;
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning */ protected void setWarning(String warning) { this.setWarning(new SQLWarning(warning)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning */ protected void setWarning(String warning) { this.setWarning(new SQLWarning(warning)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning * @param cause * Cause */ protected void setWarning(String warning, Throwable cause) { this.setWarning(new SQLWarning(warning, cause)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning */ protected void setWarning(String warning) { this.setWarning(new SQLWarning(warning)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning * @param cause * Cause */ protected void setWarning(String warning, Throwable cause) { this.setWarning(new SQLWarning(warning, cause)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning * @param cause * Cause */ protected void setWarning(String warning, Throwable cause) { this.setWarning(new SQLWarning(warning, cause)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning */ protected void setWarning(String warning) { this.setWarning(new SQLWarning(warning)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning * @param cause * Cause */ protected void setWarning(String warning, Throwable cause) { this.setWarning(new SQLWarning(warning, cause)); }
/** * Helper method that derived classes may use to set warnings * * @param warning * Warning */ protected void setWarning(String warning) { this.setWarning(new SQLWarning(warning)); }
public void close() throws SQLException { //System.err.print("ADRIAN -- "); new SQLWarning("Connection.close() called!").printStackTrace(); super.close(); } }
/** * Converts a single warning notice to a single SQLWarning * * @param notice Notice to convert * @return SQLWarning */ public static SQLWarning makeSQLWarning(Notice notice) { // if (!notice.isWarning()) { // throw new IllegalArgumentException("Notice not warning: " + notice.getCode() + ": " + notice.getMessage()); // } return new SQLWarning(notice.getMessage(), notice.getCode()); }