Package org.eclipse.jetty.server.session
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.
-
-
Constructor Summary
Constructors Constructor Description DatabaseAdaptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadaptTo(DatabaseMetaData dbMeta)StringconvertIdentifier(String identifier)Convert a camel case identifier into either upper or lower depending on the way the db stores identifiers.InputStreamgetBlobInputStream(ResultSet result, String columnName)StringgetBlobType()protected ConnectiongetConnection()Get a connection from the driver or datasource.StringgetConnectionUrl()DataSourcegetDatasource()StringgetDatasourceName()StringgetDBName()DrivergetDriver()StringgetDriverClassName()StringgetLongType()StringgetStringType()voidinitialize()booleanisEmptyStringNull()booleanisRowIdReserved()rowId is a reserved word for Oracle, so change the name of this columnvoidsetBlobType(String blobType)voidsetDatasource(DataSource ds)voidsetDatasourceName(String jndi)voidsetDriverInfo(String driverClassName, String connectionUrl)Configure jdbc connection information via a jdbc DrivervoidsetDriverInfo(Driver driverClass, String connectionUrl)Configure jdbc connection information via a jdbc DrivervoidsetLongType(String longType)voidsetStringType(String stringType)StringtoString()
-
-
-
Method Detail
-
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 classnameconnectionUrl- the driver connection url
-
setDriverInfo
public void setDriverInfo(Driver driverClass, String connectionUrl)
Configure jdbc connection information via a jdbc Driver- Parameters:
driverClass- the driver classconnectionUrl- 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()
-
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:
toStringin classObject- See Also:
Object.toString()
-
-