title: Tomcat webcontainer - how to access an ssl encrypted oracle database
body: <p>We configured our Oracle 11g (v11.2.0) database to use SSL encryption (Oracle Advanced Security).
  We did so following the instructions in the SSL with <a href="http://www.oracle.com/technetwork/database/enterprise-edition/wp-oracle-jdbc-thin-ssl-130128.pdf" rel="nofollow">Oracle JDBC Thin Driver</a>. Only encryption, no authentication, which is "Case 1" in the white paper.</p>
  
  <p>Next, we developed a small test client to check if we can access the now encrypted database.
  Here's a bit of the code:</p>
  
  <pre><code>String url = "jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=our_host)"
        + "(PORT=2484))(CONNECT_DATA=(SERVICE_NAME=our_service_name)))";
  
  System.out.println("set properties");
  Properties props = new Properties();
  props.setProperty("user", "system");
  props.setProperty("password", "our_password");
  props.setProperty("oracle.net.ssl_cipher_suites",
                      "(SSL_DH_anon_WITH_3DES_EDE_CBC_SHA, "
                          + "SSL_DH_anon_WITH_RC4_128_MD5,"
                          + "SSL_DH_anon_WITH_DES_CBC_SHA)");
  
  System.out.println("get connection");
  Connection con = DriverManager.getConnection(url, props);
  System.out.println("got a connection");
  Statement stmt = con.createStatement();
  ResultSet rs = stmt.executeQuery("select sysdate from dual");
  while (rs.next()) {
    System.out.println("result = "+rs.getString(1));
  }
  rs.close();
  stmt.close();
  con.close();
  </code></pre>
  
  <p>This works just fine and spits out the correct value. But alas is just a test client. Now we have to configure our Tomcat (v7.0.21) webcontainer so that our webapplication can access the now encrypted database.
  Before the encryption, we used a <code>dataSource</code> in <code>{tomcat.home}/conf/context.xml</code> which looked like this:</p>
  
  <pre><code>&lt;Context&gt;
  &lt;WatchedResource&gt;WEB-INF/web.xml&lt;/WatchedResource&gt;
  
  &lt;Resource name="our_name" auth="Container"
            driverClassName="oracle.jdbc.driver.OracleDriver" factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
            type="javax.sql.DataSource" logAbandoned="true" maxActive="30"
            maxIdle="5" maxWait="1000" removeAbandoned="true"
            removeAbandonedTimeout="60" url="jdbc:oracle:thin:@our_host:1521:our_sid"
            username="admin_user" password="admin_user" validationQuery="select sysdate from dual"
            testOnReturn="true" /&gt;
  &lt;!-- more Resources ... --&gt;
  &lt;/Context&gt;
  </code></pre>
  
  <p>I fiddled around with a couple of setups I found in some posts on the internet (<code>&lt;Connector&gt;</code> e.g. in <code>server.xml</code> - see below -, changed the jdbc thin driver url etc.), but achieved nothing. I have no clue how to proceed or even how to debug this. </p>
  
  <p>I uncommented and tested (unsuccessfully) the connector in <code>{tomcat.home}/conf/server.xml</code>:</p>
  
  <pre><code>&lt;Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
             maxThreads="200" scheme="https" secure="true"
             clientAuth="false" sslProtocol="TLS"
             ciphers="SSL_DH_anon_WITH_DES_CBC_SHA, SSL_DH_anon_WITH_RC4_128_MD5, SSL_DH_anon_WITH_3DES_EDE_CBC_SHA" /&gt;
  </code></pre>
  
  <p>We'd like to do it via .xml files as we did previously, so we don't need to ship a new release to our customer. </p>
  
  <p>If you need more information, I'm happy to provide you with everything if you tell me how and where to find it.</p>
  
  <p>Thank you for your time,</p>
  
  <p>regards</p>
  
  <p>René</p>