public class StaticSQLDatabaseType extends AbstractLogEnabled implements Configurable, SQLDatabaseType, PluginAware
SQLDatabaseType
.Modifier and Type | Field and Description |
---|---|
protected String |
_driver
The driver of the database type
|
protected I18nizableText |
_driverNotFoundMessage
The driver not found message
|
protected String |
_id
The id of the database type
|
protected I18nizableText |
_label
The label of the database type
|
protected String |
_languageEscapeTableNameTemplate
The template to escape the table name.
|
protected String |
_languageLimitQueryTemplate
The template to limit the query to a limit/offset.
|
protected String |
_pluginName
The plugin's name
|
protected String |
_template
The url template for this database type
|
protected String |
_validationQuery
The SQL query to validate the connection is still alive
|
Constructor and Description |
---|
StaticSQLDatabaseType() |
Modifier and Type | Method and Description |
---|---|
void |
configure(Configuration configuration) |
InputStream |
getBlob(ResultSet resultSet,
int pos)
Get the InputStream to read a blob
|
InputStream |
getBlob(ResultSet resultSet,
String columnName)
Get the InputStream to read a blob
|
String |
getDriver()
Get the driver of the database type.
|
I18nizableText |
getDriverNotFoundMessage()
Get the error message key when the specified driver was not found
|
String |
getId()
Get the id of the database type.
|
I18nizableText |
getLabel()
Get the label of the database type.
|
String |
getTemplate()
Get the url template to use for this database type
|
String |
getValidationQuery()
Get the query to validate a connection
|
String |
languageEscapeTableName(String tableNameToEscape)
Some db systems requires the table names to be escaped
|
String |
languageLimitQuery(String queryToLimit,
String limit,
String offset)
Add a limit/offset element to the given query
|
void |
setBlob(PreparedStatement statement,
int pos,
byte[] bytes)
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can use
SQLDatabaseType.setBlob(PreparedStatement, int, String) |
void |
setBlob(PreparedStatement statement,
int pos,
InputStream is,
long length)
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can use
SQLDatabaseType.setBlob(PreparedStatement, int, String) |
void |
setBlob(PreparedStatement statement,
int pos,
String blob)
Set an String into a blob
|
void |
setPluginInfo(String pluginName,
String featureName,
String id)
Sets the plugin info relative to the current component.
Note : The feature name may be null if the targeted component in declared at plugin level. |
getLogger, setLogger
protected I18nizableText _label
protected String _pluginName
protected String _validationQuery
protected I18nizableText _driverNotFoundMessage
protected String _languageEscapeTableNameTemplate
protected String _languageLimitQueryTemplate
public StaticSQLDatabaseType()
public void setPluginInfo(String pluginName, String featureName, String id)
PluginAware
setPluginInfo
in interface PluginAware
pluginName
- Unique identifier for the plugin hosting the extensionfeatureName
- Unique feature identifier (unique for a given pluginName)id
- Unique identifier of this componentpublic void configure(Configuration configuration) throws ConfigurationException
configure
in interface Configurable
ConfigurationException
public String getId()
SQLDatabaseType
getId
in interface SQLDatabaseType
public I18nizableText getLabel()
SQLDatabaseType
getLabel
in interface SQLDatabaseType
public String getDriver()
SQLDatabaseType
getDriver
in interface SQLDatabaseType
public String getTemplate()
SQLDatabaseType
getTemplate
in interface SQLDatabaseType
public String getValidationQuery()
SQLDatabaseType
getValidationQuery
in interface SQLDatabaseType
public I18nizableText getDriverNotFoundMessage()
SQLDatabaseType
getDriverNotFoundMessage
in interface SQLDatabaseType
public String languageEscapeTableName(String tableNameToEscape)
SQLDatabaseType
languageEscapeTableName
in interface SQLDatabaseType
tableNameToEscape
- The non-null table namepublic String languageLimitQuery(String queryToLimit, String limit, String offset)
SQLDatabaseType
languageLimitQuery
in interface SQLDatabaseType
queryToLimit
- The sql query that will be amendedlimit
- The max number of the results to returnoffset
- The initial offset of the results to returnpublic InputStream getBlob(ResultSet resultSet, String columnName) throws SQLException
SQLDatabaseType
getBlob
in interface SQLDatabaseType
resultSet
- the result set containing the blob.columnName
- columnSQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setpublic InputStream getBlob(ResultSet resultSet, int pos) throws SQLException
SQLDatabaseType
getBlob
in interface SQLDatabaseType
resultSet
- the result set containing the blob.pos
- column positionSQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setpublic void setBlob(PreparedStatement statement, int pos, String blob) throws SQLException, UnsupportedEncodingException
SQLDatabaseType
setBlob
in interface SQLDatabaseType
statement
- The satement where the blob will be setpos
- position in the statementblob
- String representing the blob. Can be nullSQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setUnsupportedEncodingException
- if UTF-8 is not supportedpublic void setBlob(PreparedStatement statement, int pos, byte[] bytes) throws SQLException
SQLDatabaseType
SQLDatabaseType.setBlob(PreparedStatement, int, String)
setBlob
in interface SQLDatabaseType
statement
- The satement where the blob will be setpos
- position in the statementbytes
- byte[] representing the blob, in UTF-8. Can be nullSQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setpublic void setBlob(PreparedStatement statement, int pos, InputStream is, long length) throws SQLException
SQLDatabaseType
SQLDatabaseType.setBlob(PreparedStatement, int, String)
setBlob
in interface SQLDatabaseType
statement
- The satement where the blob will be setpos
- position in the statementis
- inputStream to put in the blob. Can be nulllength
- length of the streamSQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set