Class DatabaseAdaptor


  • public class DatabaseAdaptor
    extends java.lang.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 Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String _blobType  
      protected java.lang.String _longType  
      protected java.lang.String _stringType  
    • Constructor Summary

      Constructors 
      Constructor Description
      DatabaseAdaptor()  
    • Field Detail

      • _blobType

        protected java.lang.String _blobType
      • _longType

        protected java.lang.String _longType
      • _stringType

        protected java.lang.String _stringType
    • Constructor Detail

      • DatabaseAdaptor

        public DatabaseAdaptor()
    • Method Detail

      • adaptTo

        public void adaptTo​(java.sql.DatabaseMetaData dbMeta)
                     throws java.sql.SQLException
        Throws:
        java.sql.SQLException
      • setBlobType

        public void setBlobType​(java.lang.String blobType)
      • getBlobType

        public java.lang.String getBlobType()
      • setLongType

        public void setLongType​(java.lang.String longType)
      • getLongType

        public java.lang.String getLongType()
      • setStringType

        public void setStringType​(java.lang.String stringType)
      • getStringType

        public java.lang.String getStringType()
      • convertIdentifier

        public java.lang.String convertIdentifier​(java.lang.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 java.lang.String getDBName()
      • getBlobInputStream

        public java.io.InputStream getBlobInputStream​(java.sql.ResultSet result,
                                                      java.lang.String columnName)
                                               throws java.sql.SQLException
        Throws:
        java.sql.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​(java.lang.String driverClassName,
                                  java.lang.String connectionUrl)
        Configure jdbc connection information via a jdbc Driver
        Parameters:
        driverClassName - the driver classname
        connectionUrl - the driver connection url
      • setDriverInfo

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

        public void setDatasource​(javax.sql.DataSource ds)
      • setDatasourceName

        public void setDatasourceName​(java.lang.String jndi)
      • getDatasourceName

        public java.lang.String getDatasourceName()
      • getDatasource

        public javax.sql.DataSource getDatasource()
      • getDriverClassName

        public java.lang.String getDriverClassName()
      • getDriver

        public java.sql.Driver getDriver()
      • getConnectionUrl

        public java.lang.String getConnectionUrl()
      • initialize

        public void initialize()
                        throws java.lang.Exception
        Throws:
        java.lang.Exception
      • getConnection

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

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
        See Also:
        Object.toString()