Class DbConfig

java.lang.Object
net.hironico.minisql.DbConfig
All Implemented Interfaces:
Cloneable

public class DbConfig extends Object implements Cloneable
  • Field Details

    • name

      public String name
    • jdbcUrl

      public String jdbcUrl
    • driverClassName

      public String driverClassName
    • user

      public String user
    • password

      public String password
    • batchStatementSeparator

      public String batchStatementSeparator
    • color

      public String color
  • Constructor Details

    • DbConfig

      public DbConfig()
  • Method Details

    • clone

      public Object clone() throws CloneNotSupportedException
      Overrides:
      clone in class Object
      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

      Throws:
      ClassNotFoundException
      SQLException
      InstantiationException
      IllegalAccessException
    • encryptPassword

      public static String encryptPassword(String clearPassword)
    • decryptPassword

      public static String decryptPassword(String encryptedPassword)
    • toEntityManagerFactory

      public javax.persistence.EntityManagerFactory toEntityManagerFactory(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.
      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 ocnfigure
      additionalProperties - 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

      public String toString()
      Overrides:
      toString in class Object