Class DatabaseAdaptor

java.lang.Object
org.eclipse.jetty.server.session.DatabaseAdaptor

public class DatabaseAdaptor extends Object
DatabaseAdaptor Handles differences between databases. Postgres uses the getBytes and setBinaryStream methods to access a "bytea" datatype, which can be up to 1Gb of binary data. MySQL is happy to use the "blob" type and getBlob() methods instead.
  • Field Details

    • _blobType

      protected String _blobType
    • _longType

      protected String _longType
    • _stringType

      protected String _stringType
  • Constructor Details

    • DatabaseAdaptor

      public DatabaseAdaptor()
  • Method Details

    • adaptTo

      public void adaptTo(DatabaseMetaData dbMeta) throws SQLException
      Throws:
      SQLException
    • setBlobType

      public void setBlobType(String blobType)
    • getBlobType

      public String getBlobType()
    • setLongType

      public void setLongType(String longType)
    • getLongType

      public String getLongType()
    • setStringType

      public void setStringType(String stringType)
    • getStringType

      public String getStringType()
    • convertIdentifier

      public String convertIdentifier(String identifier)
      Convert a camel case identifier into either upper or lower depending on the way the db stores identifiers.
      Parameters:
      identifier - the raw identifier
      Returns:
      the converted identifier
    • getDBName

      public String getDBName()
    • getBlobInputStream

      public InputStream getBlobInputStream(ResultSet result, String columnName) throws SQLException
      Throws:
      SQLException
    • isEmptyStringNull

      public boolean isEmptyStringNull()
    • isRowIdReserved

      public boolean isRowIdReserved()
      rowId is a reserved word for Oracle, so change the name of this column
      Returns:
      true if db in use is oracle
    • setDriverInfo

      public void setDriverInfo(String driverClassName, String connectionUrl)
      Configure jdbc connection information via a jdbc Driver
      Parameters:
      driverClassName - the driver classname
      connectionUrl - the driver connection url
    • setDriverInfo

      public void setDriverInfo(Driver driverClass, String connectionUrl)
      Configure jdbc connection information via a jdbc Driver
      Parameters:
      driverClass - the driver class
      connectionUrl - the driver connection url
    • setDatasource

      public void setDatasource(DataSource ds)
    • setDatasourceName

      public void setDatasourceName(String jndi)
    • getDatasourceName

      public String getDatasourceName()
    • getDatasource

      public DataSource getDatasource()
    • getDriverClassName

      public String getDriverClassName()
    • getDriver

      public Driver getDriver()
    • getConnectionUrl

      public String getConnectionUrl()
    • initialize

      public void initialize() throws Exception
      Throws:
      Exception
    • getConnection

      protected Connection getConnection() throws SQLException
      Get a connection from the driver or datasource.
      Returns:
      the connection for the datasource
      Throws:
      SQLException - if unable to get the connection
    • toString

      public String toString()
      Overrides:
      toString in class Object