title: How to configure Oracle's Database Network Encryption with MyBatis?
body: <p>I have a requirement to encrypt the data in transit between the web server and the database server using Mybatis as the persistence framework.</p>
  
  <p>The database server is Oracle 12c Enterprise Edition Release 12.1.0.2.0 - 64bit.  I am using the ojdbc7.jar driver.</p>
  
  <p>I am able to establish an encrypted connection as described here... <a href="https://docs.oracle.com/database/121/DBSEG/asojbdc.htm#DBSEG9613" rel="nofollow noreferrer">https://docs.oracle.com/database/121/DBSEG/asojbdc.htm#DBSEG9613</a>.  However, I have not been able to do so through MyBatis.  I am setting the connection properties in the mybatis-config.xml file.  Below are the contents of that file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE configuration PUBLIC '-//mybatis.org//DTD Config 3.0//EN' 'http://mybatis.org/dtd/mybatis-3-config.dtd'&gt;
  
  &lt;configuration&gt;
  &lt;settings&gt;
      &lt;setting name="lazyLoadingEnabled" value="false" /&gt;
      &lt;setting name="jdbcTypeForNull" value="NULL"/&gt;
  &lt;/settings&gt;
  &lt;environments default="development"&gt;     
      &lt;environment id="development"&gt;
          &lt;transactionManager type="JDBC" /&gt;
          &lt;dataSource type="POOLED"&gt;
              &lt;property name="driver" value="oracle.jdbc.OracleDriver"/&gt;
              &lt;property name="url" value="jdbc:oracle:thin:@//&lt;server&gt;:&lt;port&gt;/&lt;service&gt;"/&gt;
              &lt;property name="username" value="&lt;username&gt;"/&gt;
              &lt;property name="password" value="&lt;password&gt;"/&gt;
              &lt;property name="poolMaximumActiveConnections" value="20"/&gt;
              &lt;property name="poolMaximumIdleConnections" value="10"/&gt;
              &lt;property name="poolMaximumCheckoutTime" value="180000"/&gt;
              &lt;property name="poolPingQuery" value="select 0 from dual"/&gt;
              &lt;property name="poolPingEnabled" value="true"/&gt;
              &lt;property name="poolPingConnectionsNotUsedFor" value="1800000"/&gt;
              &lt;property name="CONNECTION_PROPERTY_THIN_NET_ENCRYPTION_LEVEL" value="REQUIRED"/&gt;
              &lt;property name="CONNECTION_PROPERTY_THIN_NET_ENCRYPTION_TYPES" value="AES256"/&gt;
          &lt;/dataSource&gt;
      &lt;/environment&gt;
  &lt;/environments&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>The last two property elements are my attempt at configuring an encrypted connection.  Without them I am able to connect successfully without encryption.  With the last two property elements I just get an error:</p>
  
  <blockquote>
    <p>Caused by: org.apache.ibatis.exceptions.PersistenceException: ###
    Error building SqlSession. ### The error may exist in SQL Mapper
    Configuration ### Cause: org.apache.ibatis.builder.BuilderException:
    Error parsing SQL Mapper Configuration. Cause:
    org.apache.ibatis.datasource.DataSourceException: Unknown DataSource
    property: CONNECTION_PROPERTY_THIN_NET_ENCRYPTION_TYPES</p>
  </blockquote>
  
  <p>Does anybody know how to solve this?</p>