Interface SQLDatabaseType
- All Known Implementing Classes:
DerbySQLDatabaseType
,PostgreSQLDatabaseType
,StaticSQLDatabaseType
public interface SQLDatabaseType
Interface for the SQL database types
-
Method Summary
Modifier and TypeMethodDescriptionGet the InputStream to read a blobGet the InputStream to read a blobGet the driver of the database type.Get the error message key when the specified driver was not foundgetId()
Get the id of the database type.getLabel()
Get the label of the database type.Get the url template to use for this database typeGet the query to validate a connectionlanguageEscapeTableName
(String tableNameToEscape) Some db systems requires the table names to be escapedlanguageLimitQuery
(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 Details
-
getId
Get the id of the database type.- Returns:
- the id. Can not be null.
-
getLabel
Get the label of the database type.- Returns:
- the label
-
getDriver
Get the driver of the database type.- Returns:
- the driver. Can not be null.
-
getValidationQuery
Get the query to validate a connection- Returns:
- A SQL query to ensure that a connection is still alive
-
getTemplate
Get the url template to use for this database type- Returns:
- the url template
-
getDriverNotFoundMessage
Get the error message key when the specified driver was not found- Returns:
- the error message
-
languageEscapeTableName
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
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
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
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
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
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
-