Class JDBCConnectionFactory

java.lang.Object
org.mybatis.generator.internal.JDBCConnectionFactory
All Implemented Interfaces:
ConnectionFactory

public class JDBCConnectionFactory extends Object implements ConnectionFactory
This class assumes that classes are cached elsewhere for performance reasons, but also to make sure that any native libraries are only loaded one time. This avoids the dreaded UnsatisfiedLinkError library loaded in another classloader.
  • Field Details

    • userId

      private String userId
    • password

      private String password
    • connectionURL

      private String connectionURL
    • driverClass

      private String driverClass
    • otherProperties

      private Properties otherProperties
  • Constructor Details

    • JDBCConnectionFactory

      public JDBCConnectionFactory(JDBCConnectionConfiguration config)
      This constructor is called when there is a JDBCConnectionConfiguration specified in the configuration.
      Parameters:
      config - the configuration
    • JDBCConnectionFactory

      public JDBCConnectionFactory()
      This constructor is called when this connection factory is specified as the type in a ConnectionFactory configuration element.
  • Method Details

    • getConnection

      public Connection getConnection() throws SQLException
      Description copied from interface: ConnectionFactory
      Should return a connection to the database in use for this context. The generator will call this method only one time for each context. The generator will close the connection.
      Specified by:
      getConnection in interface ConnectionFactory
      Returns:
      the connection
      Throws:
      SQLException - if there is some error obtaining the connection
    • getDriver

      private Driver getDriver()
    • addConfigurationProperties

      public void addConfigurationProperties(Properties properties)
      Description copied from interface: ConnectionFactory
      Adds properties for this instance from any properties configured in the ConnectionFactory.

      This method will be called before any of the get methods.

      Specified by:
      addConfigurationProperties in interface ConnectionFactory
      Parameters:
      properties - All properties from the configuration