Class DbConnection


  • public class DbConnection
    extends java.lang.Object
    DbConnection contains JDBC Connection and associated with this connection prepared statements
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.sql.Connection connection  
      private java.util.Map<java.lang.String,​java.sql.CallableStatement> mapCallableStatements  
      private java.util.Map<java.lang.String,​java.sql.PreparedStatement> mapPreparedStatements  
      private java.sql.Statement st  
    • Constructor Summary

      Constructors 
      Constructor Description
      DbConnection​(java.sql.Connection connection)
      Constructs DbConnection
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.sql.CallableStatement getCallableStatement​(java.lang.String sql)
      Get CallableStatement If the CallableStatement is not prepared before it will be prepared and stored in map
      java.sql.Connection getConnection()
      Get JDBC Connection
      java.sql.PreparedStatement getPreparedStatement​(java.lang.String sql)
      Get PreparedStatement If the PreparedStatement is not prepared before it will be prepared and stored in map
      java.sql.Statement getStatement()
      Get Statement If the Statement is not created before it will be created and stored as class member
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • connection

        private java.sql.Connection connection
      • mapPreparedStatements

        private java.util.Map<java.lang.String,​java.sql.PreparedStatement> mapPreparedStatements
      • mapCallableStatements

        private java.util.Map<java.lang.String,​java.sql.CallableStatement> mapCallableStatements
      • st

        private java.sql.Statement st
    • Constructor Detail

      • DbConnection

        public DbConnection​(java.sql.Connection connection)
        Constructs DbConnection
        Parameters:
        connection -
    • Method Detail

      • getConnection

        public java.sql.Connection getConnection()
        Get JDBC Connection
        Returns:
        Connection
      • getPreparedStatement

        public java.sql.PreparedStatement getPreparedStatement​(java.lang.String sql)
                                                        throws java.sql.SQLException
        Get PreparedStatement If the PreparedStatement is not prepared before it will be prepared and stored in map
        Parameters:
        sql - - SQL statement
        Returns:
        PreparedStatement
        Throws:
        java.sql.SQLException
      • getCallableStatement

        public java.sql.CallableStatement getCallableStatement​(java.lang.String sql)
                                                        throws java.sql.SQLException
        Get CallableStatement If the CallableStatement is not prepared before it will be prepared and stored in map
        Parameters:
        sql - - SQL statement
        Returns:
        CallableStatement
        Throws:
        java.sql.SQLException
      • getStatement

        public java.sql.Statement getStatement()
                                        throws java.sql.SQLException
        Get Statement If the Statement is not created before it will be created and stored as class member
        Returns:
        Statement
        Throws:
        java.sql.SQLException