Class CayenneDataSource.Builder

java.lang.Object
org.apache.cayenne.datasource.CayenneDataSource.Builder
Enclosing class:
CayenneDataSource

public static class CayenneDataSource.Builder extends Object
Since:
5.0
  • Method Details

    • userName

      public CayenneDataSource.Builder userName(String userName)
    • password

      public CayenneDataSource.Builder password(String password)
    • driverClass

      public CayenneDataSource.Builder driverClass(String driverClassName)
      Sets a class name of the JDBC driver. This is optional and is only used in special circumstances. Normally, JDBC-compliant drivers are discovered automatically, and resolved based on the URL.
    • driver

      public CayenneDataSource.Builder driver(Driver driver)
      Sets an already instantiated JDBC driver, bypassing driver discovery and class loading. This is only needed when the driver can not be loaded by Cayenne's own ClassLoader, e.g. by tools that load JDBC drivers supplied by the user.
      Since:
      5.0
    • pool

      public CayenneDataSource.Builder pool(int minConnections, int maxConnections)
      Turns the built DataSource into a connection pool with the given connection count bounds.
    • maxQueueWaitTime

      public CayenneDataSource.Builder maxQueueWaitTime(long maxQueueWaitTime)
      Sets a maximum time in milliseconds a connection request may wait for a free connection in the pool. Ignored unless pool(int, int) is also called.
    • validationQuery

      public CayenneDataSource.Builder validationQuery(String validationQuery)
      Sets a SQL query used by the pool to check connection health. Ignored unless pool(int, int) is also called.
    • build

      public DataSource build()
      Builds a DataSource that is pooling if pool(int, int) was called, and non-pooling otherwise. A pooling DataSource is AutoCloseable and must be explicitly closed by the caller when no longer in use.