Class CpConnect

java.lang.Object
io.odysz.semantic.DA.AbsConnect<CpConnect>
io.odysz.semantic.DA.cp.CpConnect

public class CpConnect extends AbsConnect<CpConnect>
Pooled connection manager.
Author:
Ody
  • Constructor Details

    • CpConnect

      public CpConnect(String id, String srcId, io.odysz.common.dbtype driverType, boolean printSql, boolean log)
      Managing connection and ds for mysql, oracle, ...
      Parameters:
      srcId -
      driverType -
      printSql -
      log -
  • Method Details

    • select

      public static AnResultset select(String src, String sql) throws SQLException
      Use this for querying database without help of sql builder (which need query meta data first with this method).
      Parameters:
      src - name that matches context.xml/Resource/name, like 'inet' etc.
      sql -
      Returns:
      results
      Throws:
      SQLException
    • getlobMeta

      public HashMap<String,HashMap<String,OracleLob>> getlobMeta()
      Get the CLOBs meta data - which is built while initialization.
      Returns:
      map[tabl, [field, lob]]
    • getConnection

      protected Connection getConnection() throws SQLException, NamingException
      Get Connection

      Issue with Mysql 8.0.2:

      For mysql 8.0.0, the SSL connection is enabled by default. And got SSL connection exception:
               javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake
               Caused by: java.io.EOFException: SSL peer shut down incorrectly
      Probable caused by no certificate?
      To solve this temporarily, for pooled connect, in server.xml (tomcat), set connectionProperties="useSSL=false",
               <Resource auth="Container" 
                      connectionProperties="useUnicode=yes;characterEncoding=utf8;autoReconnect=true;autoReconnectForPools=true;useSSL=false;enabledTLSProtocols=TLSv1,TLSv1.1,TLSv1.2"
                      driverClassName="com.mysql.cj.jdbc.Driver"
                      maxActive="10" maxIdle="3" maxWait="10000"
                      global="jdbc/db-name"
                      name="jdbc/db-name" password="..."
                      type="javax.sql.DataSource"
                      url="jdbc:mysql://host:3306/db-name"
                      username="..."/>
      See This.
      Returns:
      connection
      Throws:
      SQLException - database access error occurs while get connection. See DataSource.getConnection().
      NamingException - lookup connection failed
    • select

      public AnResultset select(String sql, int flags) throws SQLException, NamingException
      For Connects creating Meta data before Datasource is usable.
      Specified by:
      select in class AbsConnect<CpConnect>
      Parameters:
      sql -
      Returns:
      query results
      Throws:
      SQLException
      NamingException
    • commit

      public int[] commit(ArrayList<String> sqls, int flags) throws SQLException, NamingException
      Specified by:
      commit in class AbsConnect<CpConnect>
      Throws:
      SQLException
      NamingException
    • truncatUtf8

      public static String truncatUtf8(String s, int maxBytes)
    • commit

      public int[] commit(io.odysz.semantics.IUser log, ArrayList<String> sqls, ArrayList<Clob> lobs, int i) throws SQLException
      Specified by:
      commit in class AbsConnect<CpConnect>
      Throws:
      SQLException