Package net.hironico.minisql
Class DbConfig
java.lang.Object
net.hironico.minisql.DbConfig
- All Implemented Interfaces:
Cloneable
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionclone()static StringdecryptPassword(String encryptedPassword) static StringencryptPassword(String clearPassword) booleantest()Test if connection parameters are valid while not throwing any exception.javax.persistence.EntityManagerFactorytoEntityManagerFactory(String name) Shortcut to toEntityManager(name, null). this method uses only the JDBC properties for user, password, driver, and URL to create the entity manager factory from this DbConfig information.javax.persistence.EntityManagerFactorytoEntityManagerFactory(String name, Map<String, Object> additionalProperties) Convert this DB config to an EntityManagerFactory used in JPA frameworks.toString()
-
Field Details
-
name
-
jdbcUrl
-
driverClassName
-
user
-
password
-
batchStatementSeparator
-
color
-
-
Constructor Details
-
DbConfig
public DbConfig()
-
-
Method Details
-
clone
- Overrides:
clonein classObject- Throws:
CloneNotSupportedException
-
test
public boolean test()Test if connection parameters are valid while not throwing any exception.- Returns:
- true if can open a new connection with the current parameters.
-
getConnection
public Connection getConnection() throws ClassNotFoundException, SQLException, InstantiationException, IllegalAccessException -
encryptPassword
-
decryptPassword
-
toEntityManagerFactory
Shortcut to toEntityManager(name, null). this method uses only the JDBC properties for user, password, driver, and URL to create the entity manager factory from this DbConfig information.- Returns:
- See Also:
-
toEntityManagerFactory
public javax.persistence.EntityManagerFactory toEntityManagerFactory(String name, Map<String, Object> additionalProperties) Convert this DB config to an EntityManagerFactory used in JPA frameworks. This method tries to look at the persistence.xml files to load the unit designated as the name given in parameter. Then the persistence unit is configured to use the connection setup of this DbConfig.- Parameters:
name- Name of the peristence unit to load and ocnfigureadditionalProperties- additional properties to include in the configuration on top of the jdbc user, password, url and driver ones.- Returns:
- Entity manager factory configured accordingly with this DbConfig or null if the peristence unit name is not found.
-
toString
-