com.amazon.redshift.jdbc.RedshiftWarningWrapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of redshift-jdbc42 Show documentation
Show all versions of redshift-jdbc42 Show documentation
Java JDBC 4.2 (JRE 8+) driver for Redshift database
The newest version!
/*
* Copyright (c) 2017, PostgreSQL Global Development Group
* See the LICENSE file in the project root for more information.
*/
package com.amazon.redshift.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 RedshiftWarningWrapper {
private final SQLWarning firstWarning;
private SQLWarning lastWarning;
RedshiftWarningWrapper(SQLWarning warning) {
firstWarning = warning;
lastWarning = warning;
}
void addWarning(SQLWarning sqlWarning) {
lastWarning.setNextWarning(sqlWarning);
lastWarning = sqlWarning;
}
SQLWarning getFirstWarning() {
return firstWarning;
}
}