Interface SQLDatabaseType
-
- All Known Implementing Classes:
DerbySQLDatabaseType
,PostgreSQLDatabaseType
,StaticSQLDatabaseType
public interface SQLDatabaseType
Interface for the SQL database types
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description InputStream
getBlob(ResultSet resultSet, int pos)
Get the InputStream to read a blobInputStream
getBlob(ResultSet resultSet, String columnName)
Get the InputStream to read a blobString
getDriver()
Get the driver of the database type.I18nizableText
getDriverNotFoundMessage()
Get the error message key when the specified driver was not foundString
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 typeString
getValidationQuery()
Get the query to validate a connectionString
languageEscapeTableName(String tableNameToEscape)
Some db systems requires the table names to be escapedString
languageLimitQuery(String queryToLimit, String limit, String offset)
Add a limit/offset element to the given queryvoid
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 usesetBlob(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 usesetBlob(PreparedStatement, int, String)
void
setBlob(PreparedStatement statement, int pos, String blob)
Set an String into a blob
-
-
-
Method Detail
-
getLabel
I18nizableText getLabel()
Get the label of the database type.- Returns:
- the label
-
getDriver
String getDriver()
Get the driver of the database type.- Returns:
- the driver. Can not be null.
-
getValidationQuery
String getValidationQuery()
Get the query to validate a connection- Returns:
- A SQL query to ensure that a connection is still alive
-
getTemplate
String getTemplate()
Get the url template to use for this database type- Returns:
- the url template
-
getDriverNotFoundMessage
I18nizableText getDriverNotFoundMessage()
Get the error message key when the specified driver was not found- Returns:
- the error message
-
languageEscapeTableName
String languageEscapeTableName(String tableNameToEscape)
Some db systems requires the table names to be escaped- Parameters:
tableNameToEscape
- The non-null table name- Returns:
- The escaped table name or at least the table name if no escape is required
-
languageLimitQuery
String languageLimitQuery(String queryToLimit, String limit, String offset)
Add a limit/offset element to the given query- Parameters:
queryToLimit
- The sql query that will be amendedlimit
- The max number of the results to returnoffset
- The initial offset of the results to return- Returns:
- The initial query amended to handle the limit and offset.
-
getBlob
InputStream getBlob(ResultSet resultSet, String columnName) throws SQLException
Get the InputStream to read a blob- Parameters:
resultSet
- the result set containing the blob.columnName
- column- Returns:
- an InputStream to read the blob or null if the column is null
- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
-
getBlob
InputStream getBlob(ResultSet resultSet, int pos) throws SQLException
Get the InputStream to read a blob- Parameters:
resultSet
- the result set containing the blob.pos
- column position- Returns:
- an InputStream to read the blob
- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
-
setBlob
void setBlob(PreparedStatement statement, int pos, String blob) throws SQLException, UnsupportedEncodingException
Set an String into a blob- Parameters:
statement
- The satement where the blob will be setpos
- position in the statementblob
- String representing the blob. Can be null- Throws:
SQLException
- 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 supported
-
setBlob
void setBlob(PreparedStatement statement, int pos, byte[] bytes) throws SQLException
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(PreparedStatement, int, String)
- Parameters:
statement
- The satement where the blob will be setpos
- position in the statementbytes
- byte[] representing the blob, in UTF-8. Can be null- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
-
setBlob
void setBlob(PreparedStatement statement, int pos, InputStream is, long length) throws SQLException
Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(PreparedStatement, int, String)
- Parameters:
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 stream- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result set
-
-