AO Database Connectivity Changelog

ao-dbc-4.0.0

Release Notes

  • DatabaseAccess now implements transactional methods instead of them only being on Database. This allows code to accept DatabaseAccess while still being able to efficiently have its own transactional block. Previously, DatabaseAccess was typically used only for one-off database calls.

    When transactional methods are via a Database instance, the implementation is the same as before. When the transactional methods are via a DatabaseConnection, they are directly implemented on the connection.

  • New DatabaseConnection.onCommit(…) and DatabaseConnection.onRollback(…) events.
  • New set of methods that return Optional instead of throwing NoRowException.
  • Breaking change: Single-row DatabaseAccess.queryObject(…), DatabaseAccess.updateObject(…), and all related more specific type methods will no longer return null when there is a row with a SQL NULL value, instead will throw NullDataException. This was already the behavior for primitive types (and related wrappers). This aligns the behavior across all types.

    When SQL NULL values are expected, use one of the new DatabaseAccess.queryObjectNullable(…), DatabaseAccess.queryObjectOptionalNullable(…), or related more specific type methods.

  • Implemented remaining SQL types for formatted result set exceptions/logging.

ao-dbc-3.1.1

Release Notes

  • Updated dependencies.

ao-dbc-3.1.0

Release Notes

  • Localized exceptions now allow access to i18n resources used to generate localized message.

ao-dbc-3.0.0

Release Notes

  • Minimum Java version changed from 1.8 to 11.
  • Now supports Java 9+ modules with included module-info.class.
  • Maven artifact relocated from com.aoindustries:ao-dbc to com.aoapps:ao-dbc.
  • Package renamed from com.aoindustries.dbc to com.aoapps.dbc.

ao-dbc-2.1.1

Release Notes

  • Fixed bug where NoRowException (and similar) were being wrapped, which was interfering with catch blocks.

    Removed all uses of WrappedSQLException. Now registers SQL statements directly with ErrorPrinter instead. This allows the SQL statements to be logged while not altering exception types underneath the application.

ao-dbc-2.1.0

Release Notes

  • Added localization constructors to ExtraRowException, NoRowException, and NullDataException.

ao-dbc-2.0.1

Release Notes

  • Now subclassing more specific exception types where appropriate, instead of just using SQLException everywhere.

ao-dbc-2.0.0

Release Notes

  • createObject now unwraps cause from InvocationTargetException.
  • Integrated support of Throwable.addSuppressed(Throwable):
    1. DatabaseConnection.rollback() now throws SQLException, instead of logging and returning.
    2. New DatabaseConnection.rollback(Throwable) that adds any exceptions occurring during rollback to the given throwable via Throwable.addSuppressed(Throwable).
    3. Deprecated DatabaseConnection.rollbackAndClose() in favor of either explicit DatabaseConnection.rollback() or relying on the automatic rollback of transactions in-progress during DatabaseConnection.close(). Furthermore, any connection with an unresolved fail-fast state will be validated and closed as-needed before being returned to the underlying connection pool.
    4. DatabaseConnection.rollbackAndClose() (now deprecated) now throws SQLException, instead of logging and returning.
    5. New DatabaseConnection.rollbackAndClose(Throwable) (also deprecated) that adds any exceptions occurring during rollback to the given throwable via Throwable.addSuppressed(Throwable).
    6. Database.getConnection(…) now adds any exceptions occurring during clean-up (close and/or release connection) to the first throwable via Throwable.addSuppressed(Throwable).
    7. DatabaseConnection now implements AutoCloseable, with the expectation to by used via try-with-resources.
  • Any exception during SQLData initialization will now clean-up properly (close and/or release connection).
  • execute*(…) methods now also rollback on all types of Throwable except ThreadDeath and NoRowException, versus just handling Exception and below.
  • AutoCloseable implementation moved to a new class CloseableDatabase, which extends Database. This allows the return of Database in contexts where it is not expected to be closed.
  • Now logs SQLWarning from connections obtained from both AOConnectionPool and DataSource. Previously, warnings were only logged by AOConnectionPool.
  • Created ObjectFactory instances for common types in ObjectFactories.
  • execute*Query(…) and execute*Update(…) that return Java primitives, along with the specialized primitive-list executeIntList*(…) and executeLongList*(…), now throw a new NullDataException when the result returns a NULL value.

    Previously, the default conversion was used. Any code that relied on this default conversion will need to be updated: a small lambda on queryObject(…) or updateObject(…) would do the trick.

  • Moved base implementation methods from AbstractDatabaseAccess abstract class to default methods on the DatabaseAccess interface, then removed AbstractDatabaseAccess.
  • Declared throws of ExtraRowException where it may occur.
  • No longer automatically rollback transaction on ExtraRowException.
  • When Database.getConnection(…) gets a connection from an underlying DataSource, if the connection is not auto-commit, it will be rolled-back and set to auto-commit. As this is not expected to happen normally, a warning will be logged.
  • Database.getConnection(…) will no longer perform automatic commits that were to facilitate read-only and transaction isolation level changes. Exceptions may now be thrown by the underlying JDBC driver when attempts are made to change read-only state or isolation levels during a transaction; this is a safer behavior.
  • Added support for primitive double and float queries and updates.
  • Added support for Java 8+ streaming queries and updates.
  • Deprecated executeShortList*(…) methods. These offer no performance advantage over queryList(…) combined with ObjectFactories.Short, plus we do not have this type of list method for other wrapper types.
  • Deprecated executeObject*(…) methods that accept a Class<T> parameter. This class has its constructor accessed via reflection. This construct has been obsoleted by constructor lamdas Class::new used as ObjectFactory.
  • Renamed execute*Query(…) methods to query*(…).
  • Renamed execute*Update(…) methods to update*(…).
  • Deprecated ResultSetHandler and ResultSetHandlerE in favor of new ResultSetRunnable, ResultSetRunnableE, ResultSetCallable, and ResultSetCallableE. Having both runnable and callable variants allows implementations to not return anything. Previously, to satisfy the interface, something always had to be returned, even if just a (Void)null.
  • Renamed Database.executeTransaction(…) to Database.transactionCall(…) and Database.transactionRun(…).
  • Added new methods Database.transactionRun(RunnableE) and Database.transactionCall(CallableE), which are useful when a transaction scope is needed, but the DatabaseConnection itself is not required.
  • Renamed Database.createDatabaseConnection() to connect(). Since this method puts the burden of transaction management on the caller, please consider using the various transactionCall(…) or transactionRun(…) methods.
  • Added overloads of Database.getConnection(…) and DatabaseConnection.getConnection(…), paralleling the methods of the underlying AOConnectionPool.
  • NullDataException and ExtraRowException now include a summary of the row as the exception message. This implementation adds AO Encoding as new dependency.
  • Deprecated Database.releaseConnection(Connection) and DatabaseConnection.releaseConnection() in favor of Connection.close() for use in try-with-resources:
    1. New protected method Database.release(Connection) that performs the release.
    2. This implementation adds AO Concurrent as new dependency.
  • Changed generic bounds from specific to bounded, where appropriate.
  • Generic exception upper bounds changed from Exception to Throwable.
  • Now pre-sizing collections when number of rows in result set is known.
  • Added support for executeLargeUpdate.
  • Now uses the fail-fast state of the new FailFastConnection to know when to close or abort the underlying database connection.
  • Now registering exception types for use with Throwables.newSurrogate(…) that supports creating new instances of throwables in order to have caller stack trace. When wrapped, the original throwable is the cause of the new throwable. When not wrapped, the original throwable is used directly and caller stack trace is lost.

    This is used to maintain exception types and states across thread boundaries, such as when an exception cause is obtained from an ExecutionException.

  • Defined SQLSTATE values for all SQLException.
  • Fetch size increased from 1000 to 10000 rows.

    This value may be increased over time as the amount of typical system memory increases. As this may affect the number of round trips, and the speed of light is not likely to change, future increases may be of benefit.

  • Added JDBC 4.2 Types.

ao-dbc-1.4.1

Release Notes

  • Fixed bug in releaseConnection that would fail when trying to restore original type maps on a closed connection. Now checks that the connection is not closed first.

ao-dbc-1.4.0

Release Notes

  • Minimum Java version changed from 1.7 to 1.8.
  • Reduced use of property substitutions in pom.xml. This is to help 3rd-party parsers that fail to perform full Maven-compatible substitutions.
  • Database is now AutoCloseable, which closes the underlying pool.

ao-dbc-1.3.0

Release Notes

ao-dbc-1.2.1

Release Notes

  • Minimum Java version changed from 1.6 to 1.7.
  • Using managed dependencies:
    1. This project uses managed dependencies.
    2. This project's managed dependencies may also be imported by other projects.

ao-dbc-1.2.0

Release Notes

  • New set of execute*Update methods that mirror the short form of execute*Query methods, but that do not operate read-only. This alleviates most of the uses of the longer form of execute*Query. Less is more - now get back to work!
  • Now supports the automatic loading of SQLData implementations via ServiceLoader.
  • Now calling PreparedStatement.setObject(int, java.lang.Object) to give the database driver a chance to decide what to do.

ao-dbc-1.1.3

Release Notes

  • Updated dependencies.

ao-dbc-1.1.2

Release Notes

  • New AO OSS Parent POM to simplify pom.xml files.
  • Project documentation moved to per-project book in SemanticCMS format.
  • Added changelog as top-level project link.

ao-dbc-1.1.1

Release Notes

  • Improved Javadoc formatting.
  • Improved README formatting.

ao-dbc-1.1.0

Release Notes

  • Improved Javadoc formatting.
  • Improved README formatting.
  • Each lock object now a small empty class to help identify lock contention.

    The lock contention profiler in NetBeans is just showing "java.lang.Object" all over, and can't seem to get from the lock object id to the actual object in the heap dump using OQL (id not found).

ao-dbc-1.0

Release Notes

  • Project moved to GitHub and Maven.