org.postgresql.jdbc.PSQLWarningWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jdbc-yugabytedb Show documentation
Show all versions of jdbc-yugabytedb Show documentation
Java JDBC 4.2 (JRE 8+) driver for YugaByte SQL database
The newest version!
/*
* Copyright (c) 2017, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/
package org.postgresql.jdbc;
import java.sql.SQLWarning;
/**
* Wrapper class for SQLWarnings that provides an optimisation to add
* new warnings to the tail of the SQLWarning singly linked list, avoiding Θ(n) insertion time
* of calling #setNextWarning on the head. By encapsulating this into a single object it allows
* users(ie PgStatement) to atomically set and clear the warning chain.
*/
class PSQLWarningWrapper {
private final SQLWarning firstWarning;
private SQLWarning lastWarning;
PSQLWarningWrapper(SQLWarning warning) {
firstWarning = warning;
lastWarning = warning;
}
void addWarning(SQLWarning sqlWarning) {
lastWarning.setNextWarning(sqlWarning);
lastWarning = sqlWarning;
}
SQLWarning getFirstWarning() {
return firstWarning;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy