Class SQLDatabaseTypeExtensionPoint
java.lang.Object
org.ametys.runtime.plugin.component.AbstractLogEnabled
org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint<SQLDatabaseType>
org.ametys.core.datasource.dbtype.SQLDatabaseTypeExtensionPoint
- All Implemented Interfaces:
LogEnabled
,ExtensionPoint<SQLDatabaseType>
,Disposable
,Initializable
,Component
,Contextualizable
,Serviceable
,ThreadSafe
public class SQLDatabaseTypeExtensionPoint
extends AbstractThreadSafeComponentExtensionPoint<SQLDatabaseType>
This class is in charge to load and initialize the
SQLDatabaseType
-
Field Summary
Fields inherited from class org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint
_cocoonManager, _context, _manager
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the InputStream to read a blobGet the InputStream to read a blobGet the SQL database types with their labelvoid
Finalize the initialization of the extensions.
This method is called after alladdExtension()
calls.
This is the last step before the actual startup of the application.languageEscapeTableName
(String dbType, String tableNameToEscape) Some db systems requires the table names to be escapedlanguageLimitQuery
(String dbType, String queryToLimit, String limit, String offset) Add a limit/offset element to the given queryvoid
setBlob
(String dbType, 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(String, PreparedStatement, int, String)
void
setBlob
(String dbType, 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(String, PreparedStatement, int, String)
void
setBlob
(String dbType, PreparedStatement statement, int pos, String blob) Set an String into a blobMethods inherited from class org.ametys.runtime.plugin.component.AbstractThreadSafeComponentExtensionPoint
addComponent, addExtension, contextualize, dispose, getExtension, getExtensionsIds, hasExtension, initialize, service
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
Field Details
-
ROLE
Avalon Role
-
-
Constructor Details
-
SQLDatabaseTypeExtensionPoint
public SQLDatabaseTypeExtensionPoint()
-
-
Method Details
-
initializeExtensions
Description copied from interface:ExtensionPoint
Finalize the initialization of the extensions.
This method is called after alladdExtension()
calls.
This is the last step before the actual startup of the application.- Specified by:
initializeExtensions
in interfaceExtensionPoint<SQLDatabaseType>
- Overrides:
initializeExtensions
in classAbstractThreadSafeComponentExtensionPoint<SQLDatabaseType>
- Throws:
Exception
- if something wrong occurs
-
getSQLDatabaseTypes
Get the SQL database types with their label- Returns:
- the SQL database types with their label
-
languageEscapeTableName
Some db systems requires the table names to be escaped- Parameters:
dbType
- The identifier of the db type usedtableNameToEscape
- The non-null table name- Returns:
- The escaped table name or at least the table name if no escape is required. Or null if the dbtype is unknown.
-
languageLimitQuery
Add a limit/offset element to the given query- Parameters:
dbType
- The identifier of the db type usedqueryToLimit
- 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. Or null if the dbtype is unknown.
-
getBlob
public InputStream getBlob(String dbType, ResultSet resultSet, String columnName) throws SQLException Get the InputStream to read a blob- Parameters:
dbType
- The identifier of the db type usedresultSet
- the result set containing the blob.columnName
- column- 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
-
getBlob
Get the InputStream to read a blob- Parameters:
dbType
- The identifier of the db type usedresultSet
- 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
public void setBlob(String dbType, PreparedStatement statement, int pos, String blob) throws SQLException, UnsupportedEncodingException, IllegalArgumentException Set an String into a blob- Parameters:
dbType
- The identifier of the db type usedstatement
- The satement where the blob will be setpos
- position in the statementblob
- String representing 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 setUnsupportedEncodingException
- if UTF-8 is not supportedIllegalArgumentException
- if the dbType is not found
-
setBlob
public void setBlob(String dbType, PreparedStatement statement, int pos, byte[] bytes) throws SQLException, IllegalArgumentException Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(String, PreparedStatement, int, String)
- Parameters:
dbType
- The identifier of the db type usedstatement
- The satement where the blob will be setpos
- position in the statementbytes
- byte[] representing the blob, in UTF-8- Throws:
SQLException
- if the columnLabel is not valid; if a database access error occurs or this method is called on a closed result setIllegalArgumentException
- if the dbType is not found
-
setBlob
public void setBlob(String dbType, PreparedStatement statement, int pos, InputStream is, long length) throws SQLException, IllegalArgumentException Set an array of bytes (UTF-8 encoded) into a blob, if you want to pass a String, you can usesetBlob(String, PreparedStatement, int, String)
- Parameters:
dbType
- The identifier of the db type usedstatement
- The satement where the blob will be setpos
- position in the statementis
- inputStream to put in the bloblength
- 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 setIllegalArgumentException
- if the dbType is not found
-