Class DataBase
java.lang.Object
ecmwf.common.database.DataGet
ecmwf.common.database.DataBase
- All Implemented Interfaces:
MBeanService
,Closeable
,AutoCloseable
- Direct Known Subclasses:
ECpdsBase
The Class DataBase.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The Constant MODE_EXTERNAL.static final int
The Constant MODE_INTERNAL.static final int
The Constant MODE_SERVER. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Clear cache.<T extends DataBaseObject>
voidclearCache
(Class<T> clazz, List<Object> primaryKeys) Clear cache for the specified entities and primary keys.void
clearCache
(String tableName, String columnName, List<Object> primaryKeys) Clear cache for the specified entities and primary keys.void
close()
Close.protected static String
Escape SQL values to avoid SQL injections.protected int
executeCountAsInt
(String menu, String name) Execute count as int.protected int
executeCountAsInt
(String menu, String name, String[] values) Execute count as int.protected long
executeCountAsLong
(String menu, String name) Execute count as long.protected long
executeCountAsLong
(String menu, String name, String[] values) Execute count as long.protected <T extends DataBaseObject>
ecmwf.common.database.DBIterator<T> executeQuery
(String menu, String name, Class<T> resultClass) Execute query.protected <T extends DataBaseObject>
ecmwf.common.database.DBIterator<T> executeQuery
(String menu, String name, Class<T> resultClass, String[] values) Execute query.protected ecmwf.common.database.DBResultSet
executeSelect
(String originalSql) Execute select.protected ecmwf.common.database.DBResultSet
executeSelect
(String menu, String name) Execute select.protected ecmwf.common.database.DBResultSet
executeSelect
(String menu, String name, String[] values) Execute select.protected int
executeUpdate
(String menu, String name) Execute update.protected int
executeUpdate
(String menu, String name, String[] values) Execute update.static final String
formatDate
(long date) Format date.static final String
formatTime
(long time) Format time.protected <T extends DataBaseObject>
Tget
(T object) Gets the.protected <T extends DataBaseObject>
ecmwf.common.database.DBIterator<T> Gets the all.getAttribute
(String attributeName) Gets the attribute.Gets the MBean info.int
getMode()
Gets the mode.Object[]
getPrimaryKeyValues
(DataBaseObject object) Gets the primary key values.getScriptFileImpl
(String repository) Gets the script file impl.static long
getTime()
Gets the time.static long
Gets the time.void
initialize
(String brokerProxy, String driverClassName, String level, String protocol, String subProtocol, String alias, String user, String password, String dbms, String serverUrl, String repository, String validation, boolean logDatabaseEvents, boolean debugSqlRequests) Initialise.void
insert
(DataBaseObject object, boolean createPk) Insert.void
insert
(DataBaseObject object, boolean createPk, boolean checkDuplicate) Insert.Invoke.protected void
logSqlRequest
(String name, long count) Log sql request.protected void
logSqlRequest
(String sql, long start, long stop, int numberOfRows) Log sql request.newActivity
(ECUser ecuser, String plugin, String host, String agent, String action, String comment, boolean error) New activity.New event.void
Reload repository.void
remove
(DataBaseObject object) Removes the.void
remove
(DataBaseObject[] objects) Removes the.byte[]
Select.boolean
setAttribute
(String name, Object value) Sets the attribute.void
store
(DataBaseObject object) Store.boolean
tryInsert
(DataBaseObject object, boolean createPk) Try to insert a DataBase Object.boolean
tryUpdate
(DataBaseObject object) Try to update a DataBase Object.void
update
(DataBaseObject object) Update a DataBase Object.Update.Methods inherited from class ecmwf.common.database.DataGet
getActivity, getActivity, getActivityObject, getAlias, getAliasArray, getAliasObject, getAssociation, getAssociationArray, getAssociationObject, getAuthorizedECUser, getAuthorizedECUserObject, getCategory, getCategoryArray, getCategoryObject, getCatUrl, getCatUrlArray, getCatUrlObject, getCountry, getCountryArray, getCountryObject, getDataFile, getDataFile, getDataFileObject, getDataTransfer, getDataTransferObject, getDestination, getDestinationArray, getDestinationECUser, getDestinationECUserArray, getDestinationECUserObject, getDestinationObject, getECSession, getECSession, getECSessionObject, getECtransAccounting, getECtransAccounting, getECtransAccountingObject, getECtransDestination, getECtransDestinationArray, getECtransDestinationObject, getECtransModule, getECtransModuleArray, getECtransModuleObject, getECUser, getECUserArray, getECUserObject, getEvent, getEvent, getEventObject, getHost, getHostArray, getHostArray, getHostECUser, getHostECUserObject, getHostLocation, getHostLocationObject, getHostObject, getHostOutput, getHostOutputObject, getHostStats, getHostStatsObject, getHostWithOutput, getIncomingAssociationArray, getIncomingPolicy, getIncomingPolicyArray, getIncomingPolicyObject, getIncomingUser, getIncomingUserArray, getIncomingUserObject, getMetadataAttribute, getMetadataAttributeArray, getMetadataAttributeObject, getMonitoringValue, getMonitoringValue, getMonitoringValueObject, getNotification, getNotification, getNotificationObject, getOperation, getOperationArray, getOperationObject, getPermission, getPermissionObject, getPolicyAssociation, getPrivileged, getPrivilegedObject, getProductStatus, getProductStatus, getProductStatusArray, getProductStatusObject, getPublication, getPublication, getPublicationIterator, getPublicationObject, getReception, getReception, getReceptionObject, getSchedulerValue, getSchedulerValue, getSchedulerValueObject, getSpool, getSpool, getSpoolObject, getTransferECUser, getTransferECUserObject, getTransferGroup, getTransferGroupArray, getTransferGroupObject, getTransferHistory, getTransferHistory, getTransferHistoryObject, getTransferMethod, getTransferMethodArray, getTransferMethodObject, getTransferModule, getTransferModuleArray, getTransferModuleObject, getTransferServer, getTransferServerArray, getTransferServerObject, getUrl, getUrlArray, getUrlObject, getWebUser, getWebUserArray, getWebUserObject, getWeuCat, getWeuCatArray, getWeuCatObject
-
Field Details
-
MODE_EXTERNAL
public static final int MODE_EXTERNALThe Constant MODE_EXTERNAL.- See Also:
-
MODE_INTERNAL
public static final int MODE_INTERNALThe Constant MODE_INTERNAL.- See Also:
-
MODE_SERVER
public static final int MODE_SERVERThe Constant MODE_SERVER.- See Also:
-
-
Constructor Details
-
DataBase
public DataBase()
-
-
Method Details
-
initialize
public void initialize(String brokerProxy, String driverClassName, String level, String protocol, String subProtocol, String alias, String user, String password, String dbms, String serverUrl, String repository, String validation, boolean logDatabaseEvents, boolean debugSqlRequests) throws SQLException, IllegalAccessException, InstantiationException, ClassNotFoundException, DataBaseException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException Initialise.- Parameters:
brokerProxy
- the broker proxydriverClassName
- the driverlevel
- the levelprotocol
- the protocolsubProtocol
- the sub protocolalias
- the aliasuser
- the userpassword
- the passworddbms
- the dbmsserverUrl
- the serverrepository
- the repositoryvalidation
- the validationlogDatabaseEvents
- the log eventsdebugSqlRequests
- the debug sql- Throws:
SQLException
- the SQL exceptionIllegalAccessException
- the illegal access exceptionInstantiationException
- the instantiation exceptionClassNotFoundException
- the class not found exceptionDataBaseException
- the data base exceptionIllegalArgumentException
- the illegal argument exceptionInvocationTargetException
- the invocation target exceptionNoSuchMethodException
- the no such method exceptionSecurityException
- the security exception
-
formatDate
Format date.- Parameters:
date
- the date- Returns:
- the string
-
formatTime
Format time.- Parameters:
time
- the time- Returns:
- the string
-
reloadRepository
public void reloadRepository()Reload repository. -
close
public void close()Close.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
get
Gets the.- Throws:
DataBaseException
-
getAll
Gets the all. -
escapeSql
-
logSqlRequest
Log sql request.- Parameters:
sql
- the sqlstart
- the startstop
- the stopnumberOfRows
- the number of rows
-
logSqlRequest
Log sql request. -
executeSelect
Execute select.- Parameters:
originalSql
- the original sql- Returns:
- the DB result set
- Throws:
SQLException
- the SQL exception
-
select
Select.- Parameters:
sql
- the sql- Returns:
- the byte[]
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
update
Update.- Parameters:
sql
- the sql- Returns:
- the string
- Throws:
SQLException
- the SQL exception
-
executeSelect
protected ecmwf.common.database.DBResultSet executeSelect(String menu, String name) throws SQLException, IOException Execute select.- Parameters:
menu
- the menuname
- the name- Returns:
- the DB result set
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeSelect
protected ecmwf.common.database.DBResultSet executeSelect(String menu, String name, String[] values) throws SQLException, IOException Execute select.- Parameters:
menu
- the menuname
- the namevalues
- the values- Returns:
- the DB result set
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeQuery
protected <T extends DataBaseObject> ecmwf.common.database.DBIterator<T> executeQuery(String menu, String name, Class<T> resultClass) throws SQLException, IOException Execute query.- Type Parameters:
T
- the generic type- Parameters:
menu
- the menuname
- the nameresultClass
- the result class- Returns:
- the DB iterator
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeQuery
protected <T extends DataBaseObject> ecmwf.common.database.DBIterator<T> executeQuery(String menu, String name, Class<T> resultClass, String[] values) throws SQLException, IOException Execute query.- Type Parameters:
T
- the generic type- Parameters:
menu
- the menuname
- the nameresultClass
- the result classvalues
- the values- Returns:
- the DB iterator
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeCountAsInt
Execute count as int.- Parameters:
menu
- the menuname
- the name- Returns:
- the int
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeCountAsInt
protected int executeCountAsInt(String menu, String name, String[] values) throws SQLException, IOException Execute count as int.- Parameters:
menu
- the menuname
- the namevalues
- the values- Returns:
- the int
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeCountAsLong
Execute count as long.- Parameters:
menu
- the menuname
- the name- Returns:
- the long
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeCountAsLong
protected long executeCountAsLong(String menu, String name, String[] values) throws SQLException, IOException Execute count as long.- Parameters:
menu
- the menuname
- the namevalues
- the values- Returns:
- the long
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeUpdate
Execute update.- Parameters:
menu
- the menuname
- the name- Returns:
- the int
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
executeUpdate
protected int executeUpdate(String menu, String name, String[] values) throws SQLException, IOException Execute update.- Parameters:
menu
- the menuname
- the namevalues
- the values- Returns:
- the int
- Throws:
SQLException
- the SQL exceptionIOException
- Signals that an I/O exception has occurred.
-
getAttribute
Gets the attribute. Gets the attribute.- Specified by:
getAttribute
in interfaceMBeanService
- Parameters:
attributeName
- the attribute name- Returns:
- the attribute
- Throws:
AttributeNotFoundException
- the attribute not found exceptionMBeanException
- the MBean exception
-
setAttribute
public boolean setAttribute(String name, Object value) throws InvalidAttributeValueException, MBeanException Sets the attribute. Sets the attribute.- Specified by:
setAttribute
in interfaceMBeanService
- Parameters:
name
- the namevalue
- the value- Returns:
- true, if successful
- Throws:
InvalidAttributeValueException
- the invalid attribute value exceptionMBeanException
- the MBean exception
-
getMBeanInfo
Gets the MBean info. Gets the MBean info.- Specified by:
getMBeanInfo
in interfaceMBeanService
- Returns:
- the MBean info
-
getMode
public int getMode()Gets the mode.- Returns:
- the mode
-
getTime
Gets the time.- Returns:
- the time
- Throws:
ParseException
- the parse exception
-
getTime
Gets the time.- Parameters:
date
- the datetime
- the time- Returns:
- the time
- Throws:
ParseException
- the parse exception
-
invoke
public Object invoke(String operationName, Object[] params, String[] signature) throws NoSuchMethodException, MBeanException Invoke. Invoke.- Specified by:
invoke
in interfaceMBeanService
- Parameters:
operationName
- the operation nameparams
- the paramssignature
- the signature- Returns:
- the object
- Throws:
NoSuchMethodException
- the no such method exceptionMBeanException
- the MBean exception
-
newActivity
public Activity newActivity(ECUser ecuser, String plugin, String host, String agent, String action, String comment, boolean error) New activity.- Parameters:
ecuser
- the ecuserplugin
- the pluginhost
- the hostagent
- the agentaction
- the actioncomment
- the commenterror
- the error- Returns:
- the activity
-
newEvent
-
insert
Insert.- Parameters:
object
- the objectcreatePk
- the create pk- Throws:
DataBaseException
- the data base exception
-
insert
public void insert(DataBaseObject object, boolean createPk, boolean checkDuplicate) throws DataBaseException Insert.- Parameters:
object
- the objectcreatePk
- the create pkcheckDuplicate
- the check duplicate- Throws:
DataBaseException
- the data base exception
-
update
Update a DataBase Object.- Parameters:
object
- the object- Throws:
DataBaseException
- the data base exception
-
tryUpdate
Try to update a DataBase Object. In case of problem it will fail silently.- Parameters:
object
- the object- Returns:
- true, if successful
-
tryInsert
Try to insert a DataBase Object. In case of problem it will fail silently.- Parameters:
object
- the objectcreatePk
- the create pk- Returns:
- true, if successful
-
store
Store.- Parameters:
object
- the object- Throws:
DataBaseException
- the data base exception
-
remove
Removes the.- Parameters:
object
- the object- Throws:
DataBaseException
- the data base exception
-
remove
Removes the.- Parameters:
objects
- the objects- Throws:
DataBaseException
- the data base exception
-
clearCache
public void clearCache()Clear cache. -
clearCache
Clear cache for the specified entities and primary keys.- Type Parameters:
T
- the generic type- Parameters:
clazz
- the clazzprimaryKeys
- the primary keys
-
clearCache
-
getPrimaryKeyValues
Gets the primary key values.- Parameters:
object
- the object- Returns:
- the primary key values
- Throws:
DataBaseException
- the data base exception
-
getScriptFileImpl
Gets the script file impl.- Parameters:
repository
- the repository- Returns:
- the script file impl
-