Class MyDBConnectionInfo
java.lang.Object
org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<E,I>
org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity<MyDBConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
org.silverpeas.components.mydb.model.MyDBConnectionInfo
- All Implemented Interfaces:
Serializable,org.silverpeas.core.persistence.datasource.model.IdentifiableEntity
@Entity
public class MyDBConnectionInfo
extends org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity<MyDBConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
Information about a connexion to a data source. Such information is the name of the
data source and the credentials required to access that data source.
- Author:
- mmoquillon
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidChecks the connection with the remote data source referred in thisMyDBConnectionInfoinstance.booleanintGets the maximum number of data to return when requesting the data source.Gets the JNDI name of the data source targeted by this connection information.Gets the name of the table to load with this connexion information.static List<MyDBConnectionInfo>getFromComponentInstance(String instanceId) getLogin()Gets the user identifier used in the data source authentication.Gets the password associated with the login to connect the data source.inthashCode()booleanIs the name of the default table to load is defined?booleanIs this connection information defined?Opens a connection to the data source targeted by this connection information.static voidremoveFromComponentInstance(String instanceId) voidsave()Saves or updates this connection information into the persistence context in order to be able to retrieve it later.voidsetDataMaxNumber(int maxNumber) Sets the maximum number of data to select when requesting the data source.voidsetDataSourceName(String dataSourceName) Sets a new data source by its JNDI name to this connection info.voidsetDefaultTableName(String tableName) Sets the name of the default table to load with this connection information.voidsetLoginAndPassword(String login, String password) Sets the login and the password required to open a connection to the targeted data source.withDataMaxNumber(int maxNumber) Sets the maximum number of data to select when requesting the data source and returns this connection information.withDataSourceName(String dataSourceName) Sets a new data source by its JNDI name to this connection info.withDefaultTableName(String tableName) Sets the default table to defaultTable from the database with this connection information and returns the latter.withLoginAndPassword(String login, String password) Methods inherited from class org.silverpeas.core.persistence.datasource.model.jpa.BasicJpaEntity
performBeforePersist, performBeforeRemove, performBeforeUpdateMethods inherited from class org.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity
getId, getNativeId, isPersisted, setId
-
Constructor Details
-
MyDBConnectionInfo
protected MyDBConnectionInfo() -
MyDBConnectionInfo
-
-
Method Details
-
getFromComponentInstance
-
removeFromComponentInstance
-
isDefined
public boolean isDefined()Is this connection information defined? Information about a connection to a data source is defined if both it is related to a myDB application instance and the name of the data source is defined.- Returns:
- true if the connection is defined. False otherwise.
-
withDefaultTableName
Sets the default table to defaultTable from the database with this connection information and returns the latter.- Parameters:
tableName- the name of the table to load by default.- Returns:
- itself.
-
withoutAnyDefaultTable
-
withDataMaxNumber
Sets the maximum number of data to select when requesting the data source and returns this connection information.- Parameters:
maxNumber- the maximum number of data to return. 0 means all.- Returns:
- itself.
-
withLoginAndPassword
-
withDataSourceName
Sets a new data source by its JNDI name to this connection info.- Parameters:
dataSourceName- the JNDI name of the data source to connect to.- Returns:
- itself.
-
getDataSourceName
Gets the JNDI name of the data source targeted by this connection information.- Returns:
- the JNDI name of the data source.
-
getLogin
Gets the user identifier used in the data source authentication.- Returns:
- the login.
-
getPassword
Gets the password associated with the login to connect the data source.- Returns:
- the password.
-
getDefaultTableName
Gets the name of the table to load with this connexion information.- Returns:
- the name of the default table.
-
getDataMaxNumber
public int getDataMaxNumber()Gets the maximum number of data to return when requesting the data source.- Returns:
- the maximum number of data to consider. 0 means all.
-
isDefaultTableNameDefined
public boolean isDefaultTableNameDefined()Is the name of the default table to load is defined?- Returns:
- true if the name of a default table is set, false otherwise.
-
setDataSourceName
Sets a new data source by its JNDI name to this connection info.- Parameters:
dataSourceName- the JNDI name of the data source to connect to.
-
setLoginAndPassword
Sets the login and the password required to open a connection to the targeted data source.- Parameters:
login- a login.password- the password associated with the login.
-
setDefaultTableName
Sets the name of the default table to load with this connection information.- Parameters:
tableName- the name of a table in the database.
-
setDataMaxNumber
public void setDataMaxNumber(int maxNumber) Sets the maximum number of data to select when requesting the data source.- Parameters:
maxNumber- the maximum number of data to return. 0 means all.
-
save
public void save()Saves or updates this connection information into the persistence context in order to be able to retrieve it later. -
openConnection
Opens a connection to the data source targeted by this connection information.- Returns:
- a connection against the data source referred by this object.
- Throws:
MyDBException
-
equals
- Overrides:
equalsin classorg.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<MyDBConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
-
hashCode
public int hashCode()- Overrides:
hashCodein classorg.silverpeas.core.persistence.datasource.model.jpa.AbstractJpaEntity<MyDBConnectionInfo,org.silverpeas.core.persistence.datasource.model.identifier.UniqueIntegerIdentifier>
-
checkConnection
Checks the connection with the remote data source referred in thisMyDBConnectionInfoinstance.If the connection cannot be established with the data source, a
MyDBExceptionexception is thrown. This occurs when:- no connection information is set for the underlying component instance,
- the connection information isn't correct,
- the connection information is correct but the connection with the data source fails at this time.
- Throws:
MyDBException- if the connection cannot be established with the data source referred by thisMyDBConnectionInfoinstance.
-