Package org.eclipse.jetty.server.session
Class DatabaseAdaptor
- java.lang.Object
-
- org.eclipse.jetty.server.session.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()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
adaptTo(java.sql.DatabaseMetaData dbMeta)
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.java.io.InputStream
getBlobInputStream(java.sql.ResultSet result, java.lang.String columnName)
java.lang.String
getBlobType()
protected java.sql.Connection
getConnection()
Get a connection from the driver or datasource.java.lang.String
getConnectionUrl()
javax.sql.DataSource
getDatasource()
java.lang.String
getDatasourceName()
java.lang.String
getDBName()
java.sql.Driver
getDriver()
java.lang.String
getDriverClassName()
java.lang.String
getLongType()
java.lang.String
getStringType()
void
initialize()
boolean
isEmptyStringNull()
boolean
isRowIdReserved()
rowId is a reserved word for Oracle, so change the name of this columnvoid
setBlobType(java.lang.String blobType)
void
setDatasource(javax.sql.DataSource ds)
void
setDatasourceName(java.lang.String jndi)
void
setDriverInfo(java.lang.String driverClassName, java.lang.String connectionUrl)
Configure jdbc connection information via a jdbc Drivervoid
setDriverInfo(java.sql.Driver driverClass, java.lang.String connectionUrl)
Configure jdbc connection information via a jdbc Drivervoid
setLongType(java.lang.String longType)
void
setStringType(java.lang.String stringType)
java.lang.String
toString()
-
-
-
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 classnameconnectionUrl
- 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 classconnectionUrl
- 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 classjava.lang.Object
- See Also:
Object.toString()
-
-