Java 类java.sql.SQLWarning 实例源码
项目:ProyectoPacientes
文件:StatementImpl.java
/**
* The first warning reported by calls on this Statement is returned. A
* Statement's execute methods clear its java.sql.SQLWarning chain.
* Subsequent Statement warnings will be chained to this
* java.sql.SQLWarning.
*
* <p>
* The Warning chain is automatically cleared each time a statement is (re)executed.
* </p>
*
* <p>
* <B>Note:</B> If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
* </p>
*
* @return the first java.sql.SQLWarning or null
*
* @exception SQLException
* if a database access error occurs
*/
public java.sql.SQLWarning getWarnings() throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
if (this.clearWarningsCalled) {
return null;
}
if (this.connection.versionMeetsMinimum(4, 1, 0)) {
SQLWarning pendingWarningsFromServer = SQLError.convertShowWarningsToSQLWarnings(this.connection);
if (this.warningChain != null) {
this.warningChain.setNextWarning(pendingWarningsFromServer);
} else {
this.warningChain = pendingWarningsFromServer;
}
return this.warningChain;
}
return this.warningChain;
}
}
项目:ProyectoPacientes
文件:StatementRegressionTest.java
/**
* Tests fix for BUG#18740 - Data truncation and getWarnings() only returns
* last warning in set.
*
* @throws Exception
* if the test fails.
*/
public void testBug18740() throws Exception {
if (!versionMeetsMinimum(5, 0, 2)) {
createTable("testWarnings", "(field1 smallint(6), field2 varchar(6), UNIQUE KEY field1(field1))");
try {
this.stmt.executeUpdate(
"INSERT INTO testWarnings VALUES (10001, 'data1'), (10002, 'data2 foo'), (10003, 'data3'), (10004999, 'data4'), (10005, 'data5')");
} catch (SQLException sqlEx) {
String sqlStateToCompare = "01004";
if (isJdbc4()) {
sqlStateToCompare = "22001";
}
assertEquals(sqlStateToCompare, sqlEx.getSQLState());
assertEquals(sqlStateToCompare, sqlEx.getNextException().getSQLState());
SQLWarning sqlWarn = this.stmt.getWarnings();
assertEquals("01000", sqlWarn.getSQLState());
assertEquals("01000", sqlWarn.getNextWarning().getSQLState());
}
}
}
项目:lams
文件:SchemaExport.java
private void execute(boolean script, boolean export, Writer fileOutput, Statement statement, final String sql)
throws IOException, SQLException {
final SqlExceptionHelper sqlExceptionHelper = new SqlExceptionHelper();
String formatted = formatter.format( sql );
if (delimiter != null) formatted += delimiter;
if (script) System.out.println(formatted);
LOG.debug(formatted);
if ( outputFile != null ) {
fileOutput.write( formatted + "\n" );
}
if ( export ) {
statement.executeUpdate( sql );
try {
SQLWarning warnings = statement.getWarnings();
if ( warnings != null) {
sqlExceptionHelper.logAndClearWarnings( connectionHelper.getConnection() );
}
}
catch( SQLException sqle ) {
LOG.unableToLogSqlWarnings(sqle);
}
}
}
项目:BibliotecaPS
文件:StatementRegressionTest.java
/**
* Tests fix for BUG#18740 - Data truncation and getWarnings() only returns
* last warning in set.
*
* @throws Exception
* if the test fails.
*/
public void testBug18740() throws Exception {
if (!versionMeetsMinimum(5, 0, 2)) {
createTable("testWarnings", "(field1 smallint(6), field2 varchar(6), UNIQUE KEY field1(field1))");
try {
this.stmt.executeUpdate(
"INSERT INTO testWarnings VALUES (10001, 'data1'), (10002, 'data2 foo'), (10003, 'data3'), (10004999, 'data4'), (10005, 'data5')");
} catch (SQLException sqlEx) {
String sqlStateToCompare = "01004";
if (isJdbc4()) {
sqlStateToCompare = "22001";
}
assertEquals(sqlStateToCompare, sqlEx.getSQLState());
assertEquals(sqlStateToCompare, sqlEx.getNextException().getSQLState());
SQLWarning sqlWarn = this.stmt.getWarnings();
assertEquals("01000", sqlWarn.getSQLState());
assertEquals("01000", sqlWarn.getNextWarning().getSQLState());
}
}
}
项目:OpenVertretung
文件:StatementImpl.java
/**
* The first warning reported by calls on this Statement is returned. A
* Statement's execute methods clear its java.sql.SQLWarning chain.
* Subsequent Statement warnings will be chained to this
* java.sql.SQLWarning.
*
* <p>
* The Warning chain is automatically cleared each time a statement is (re)executed.
* </p>
*
* <p>
* <B>Note:</B> If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
* </p>
*
* @return the first java.sql.SQLWarning or null
*
* @exception SQLException
* if a database access error occurs
*/
public java.sql.SQLWarning getWarnings() throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
if (this.clearWarningsCalled) {
return null;
}
if (this.connection.versionMeetsMinimum(4, 1, 0)) {
SQLWarning pendingWarningsFromServer = SQLError.convertShowWarningsToSQLWarnings(this.connection);
if (this.warningChain != null) {
this.warningChain.setNextWarning(pendingWarningsFromServer);
} else {
this.warningChain = pendingWarningsFromServer;
}
return this.warningChain;
}
return this.warningChain;
}
}
项目:lams
文件:StatementImpl.java
/**
* The first warning reported by calls on this Statement is returned. A
* Statement's execute methods clear its java.sql.SQLWarning chain.
* Subsequent Statement warnings will be chained to this
* java.sql.SQLWarning.
*
* <p>
* The Warning chain is automatically cleared each time a statement is (re)executed.
* </p>
*
* <p>
* <B>Note:</B> If you are processing a ResultSet then any warnings associated with ResultSet reads will be chained on the ResultSet object.
* </p>
*
* @return the first java.sql.SQLWarning or null
*
* @exception SQLException
* if a database access error occurs
*/
public java.sql.SQLWarning getWarnings() throws SQLException {
synchronized (checkClosed().getConnectionMutex()) {
if (this.clearWarningsCalled) {
return null;
}
if (this.connection.versionMeetsMinimum(4, 1, 0)) {
SQLWarning pendingWarningsFromServer = SQLError.convertShowWarningsToSQLWarnings(this.connection);
if (this.warningChain != null) {
this.warningChain.setNextWarning(pendingWarningsFromServer);
} else {
this.warningChain = pendingWarningsFromServer;
}
return this.warningChain;
}
return this.warningChain;
}
}
项目:openjdk-jdk10
文件:SQLWarningTests.java
/**
* Validate that the ordering of the returned SQLWarning is correct using
* traditional while loop
*/
@Test
public void test14() {
SQLWarning ex = new SQLWarning("Warning 1", t1);
SQLWarning ex1 = new SQLWarning("Warning 2");
SQLWarning ex2 = new SQLWarning("Warning 3", t2);
ex.setNextWarning(ex1);
ex.setNextWarning(ex2);
int num = 0;
SQLWarning sqe = ex;
while (sqe != null) {
assertTrue(warnings[num++].equals(sqe.getMessage()));
Throwable c = sqe.getCause();
while (c != null) {
assertTrue(msgs[num++].equals(c.getMessage()));
c = c.getCause();
}
sqe = sqe.getNextWarning();
}
}
项目:jdk8u-jdk
文件:SQLWarningTests.java
/**
* Serialize a SQLWarning and make sure you can read it back properly
*/
@Test
public void test10() throws Exception {
SQLWarning e = new SQLWarning(reason, state, errorCode, t);
SQLWarning ex1 = createSerializedException(e);
assertTrue(reason.equals(ex1.getMessage())
&& ex1.getSQLState().equals(state)
&& cause.equals(ex1.getCause().toString())
&& ex1.getErrorCode() == errorCode);
}
项目:jdk8u-jdk
文件:SQLWarningTests.java
/**
* Create SQLWarning with message, SQLState, and Throwable
*/
@Test
public void test6() {
SQLWarning ex = new SQLWarning(reason, state, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
项目:OpenDiabetes
文件:JDBCConnection.java
/**
* Sets the warning chain
*/
void setWarnings(SQLWarning w) {
synchronized (rootWarning_mutex) {
rootWarning = w;
}
}
项目:dev-courses
文件:JDBCConnection.java
/**
* Adds another SQLWarning to this Connection object's warning chain.
*
* @param w the SQLWarning to add to the chain
*/
void addWarning(SQLWarning w) {
// PRE: w is never null
synchronized (rootWarning_mutex) {
if (rootWarning == null) {
rootWarning = w;
} else {
rootWarning.setNextWarning(w);
}
}
}
项目:lams
文件:SqlExceptionHelper.java
/**
* Generic algorithm to walk the hierarchy of SQLWarnings
*
* @param warning The warning to walk
* @param handler The handler
*/
public void walkWarnings(
SQLWarning warning,
WarningHandler handler) {
if ( warning == null || handler.doProcess() ) {
return;
}
handler.prepare( warning );
while ( warning != null ) {
handler.handleWarning( warning );
warning = warning.getNextWarning();
}
}
项目:openjdk-jdk10
文件:SQLWarningTests.java
/**
* Create SQLWarning with message, SQLState, errorCode, and Throwable
*/
@Test
public void test5() {
SQLWarning ex = new SQLWarning(reason, state, errorCode, t);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == errorCode);
}
项目:jdk8u-jdk
文件:SQLWarningTests.java
/**
* Create SQLWarning with null Throwable
*/
@Test
public void test8() {
SQLWarning ex = new SQLWarning((Throwable) null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
项目:jdk8u-jdk
文件:SQLWarningTests.java
/**
* Create SQLWarning with no-arg constructor
*/
@Test
public void test1() {
SQLWarning ex = new SQLWarning();
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
项目:jdk8u-jdk
文件:SQLWarningTests.java
/**
* Create SQLWarning with message, SQLState, and error code
*/
@Test
public void test4() {
SQLWarning ex = new SQLWarning(reason, state, errorCode);
assertTrue(ex.getMessage().equals(reason)
&& ex.getSQLState().equals(state)
&& ex.getCause() == null
&& ex.getErrorCode() == errorCode);
}
项目:dev-courses
文件:JDBCStatementBase.java
/**
* processes chained warnings and any generated columns result set
*/
void performPostExecute() throws SQLException {
resultOut.clearLobResults();
generatedResult = null;
if (resultIn == null) {
return;
}
rootWarning = null;
Result current = resultIn;
while (current.getChainedResult() != null) {
current = current.getUnlinkChainedResult();
if (current.getType() == ResultConstants.WARNING) {
SQLWarning w = JDBCUtil.sqlWarning(current);
if (rootWarning == null) {
rootWarning = w;
} else {
rootWarning.setNextWarning(w);
}
} else if (current.getType() == ResultConstants.ERROR) {
errorResult = current;
} else if (current.getType() == ResultConstants.GENERATED) {
generatedResult = current;
} else if (current.getType() == ResultConstants.DATA) {
resultIn.addChainedResult(current);
}
}
if (rootWarning != null) {
connection.setWarnings(rootWarning);
}
}
项目:openjdk-jdk10
文件:SQLWarningTests.java
/**
* Create SQLWarning with null Throwable
*/
@Test
public void test8() {
SQLWarning ex = new SQLWarning((Throwable) null);
assertTrue(ex.getMessage() == null
&& ex.getSQLState() == null
&& ex.getCause() == null
&& ex.getErrorCode() == 0);
}
项目:jdk8u-jdk
文件:SQLWarningTests.java
/**
* Create SQLWarning and setting all objects to null
*/
@Test
public void test() {
SQLWarning e = new SQLWarning(null, null, errorCode, null);
assertTrue(e.getMessage() == null && e.getSQLState() == null
&& e.getCause() == null && e.getErrorCode() == errorCode);
}
项目:openjdk-jdk10
文件:SQLWarningTests.java
/**
* Create SQLWarning with Throwable
*/
@Test
public void test9() {
SQLWarning ex = new SQLWarning(t);
assertTrue(ex.getMessage().equals(cause)
&& ex.getSQLState() == null
&& cause.equals(ex.getCause().toString())
&& ex.getErrorCode() == 0);
}
项目:lams
文件:StatementWrapper.java
public SQLWarning getWarnings() throws SQLException {
try {
if (this.wrappedStmt != null) {
return this.wrappedStmt.getWarnings();
}
throw SQLError.createSQLException("Statement already closed", SQLError.SQL_STATE_ILLEGAL_ARGUMENT, this.exceptionInterceptor);
} catch (SQLException sqlEx) {
checkAndFireConnectionError(sqlEx);
}
return null;
}
项目:spanner-jdbc
文件:CloudSpannerResultSet.java
@Override
public SQLWarning getWarnings() throws SQLException
{
ensureOpen();
return null;
}
项目:spanner-jdbc
文件:AbstractCloudSpannerStatement.java
@Override
public SQLWarning getWarnings() throws SQLException
{
return null;
}
项目:parabuild-ci
文件:Util.java
public static final SQLWarning sqlWarning(HsqlException e) {
return new SQLWarning(e.getMessage(), e.getSQLState(),
e.getErrorCode());
}
项目:blanco-sfdc-jdbc-driver
文件:AbstractBlancoGenericJdbcStatement.java
public SQLWarning getWarnings() throws SQLException {
throw new SQLException("Not Implemented: getWarnings()");
}
项目:Agent-Benchmarks
文件:SimulateConnection.java
@Override public SQLWarning getWarnings() throws SQLException {
return null;
}
项目:parabuild-ci
文件:Util.java
public static final SQLWarning sqlWarning(HsqlException e) {
return new SQLWarning(e.getMessage(), e.getSQLState(),
e.getErrorCode());
}
项目:incubator-netbeans
文件:SQLExecutionResult.java
public Collection<SQLWarning> getWarnings() {
return dataView.getWarnings();
}
项目:calcite-avatica
文件:AvaticaNoopStatement.java
@Override public SQLWarning getWarnings() throws SQLException {
throw unsupported();
}
项目:Agent-Benchmarks
文件:SimulatePreparedStatement.java
@Override public SQLWarning getWarnings() throws SQLException {
return null;
}
项目:iotdb-jdbc
文件:TsfileStatement.java
@Override
public SQLWarning getWarnings() throws SQLException {
return warningChain;
}
项目:sstore-soft
文件:JDBC4ResultSet.java
@Override
public SQLWarning getWarnings() throws SQLException {
throw SQLError.noSupport();
}
项目:sstore-soft
文件:JDBC4Connection.java
@Override
public SQLWarning getWarnings() throws SQLException
{
checkClosed();
return null;
}
项目:Agent-Benchmarks
文件:SimulateStatement.java
@Override public SQLWarning getWarnings() throws SQLException {
return null;
}
项目:Agent-Benchmarks
文件:SimulatePreparedStatement.java
@Override public SQLWarning getWarnings() throws SQLException {
return null;
}
项目:sstore-soft
文件:Util.java
public static SQLWarning sqlWarning(Result r) {
return new SQLWarning(r.getMainString(), r.getSubString(),
r.getErrorCode());
}
项目:calcite-avatica
文件:AvaticaNoopConnection.java
@Override public SQLWarning getWarnings() throws SQLException {
return null;
}
项目:dremio-oss
文件:DremioPreparedStatementImpl.java
@Override
public SQLWarning getWarnings() throws SQLException {
throwIfClosed();
return super.getWarnings();
}
项目:openjdk-jdk10
文件:StubJdbcRowSetImpl.java
@Override
public SQLWarning getWarnings() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-jdk10
文件:StubWebRowSetImpl.java
@Override
public SQLWarning getWarnings() throws SQLException {
throw new UnsupportedOperationException("Not supported yet.");
}