title: Configure spring to connect to mysql over ssl
body: <p>I am connecting to MySQL over SSL from my Java application. I have configured MYSQL to support SSL and generated client certificates. I have imported server CA certificate and client certificate into keystore. This is how my code currently looks like</p>
  
  <pre><code>    String url = "jdbc:mysql://127.0.0.1:3306/MySampleDb? verifyServerCertificate =true&amp;useSSL=true&amp;requireSSL=true"
  
      System.setProperty("javax.net.ssl.keyStore","/home/cert/keystore");
      System.setProperty("javax.net.ssl.keyStorePassword","password");
      System.setProperty("javax.net.ssl.trustStore","/home/cert/truststore");
      System.setProperty("javax.net.ssl.trustStorePassword","password");
  
      Class.forName("com.mysql.jdbc.Driver");
      con = DriverManager.getConnection(url, user, password);
  </code></pre>
  
  <p>I want to use spring with C3p0 to connect to MYSQL over SSL.This is my spring configuration file which reads parameters from jdbc.properties.</p>
  
  <pre><code>&lt;bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"&gt;
      &lt;property name="driverClass" value="${jdbc.driver}"/&gt;
      &lt;property name="jdbcUrl" value="${jdbc.url}"/&gt;
      &lt;property name="user" value="${jdbc.username}"/&gt;
      &lt;property name="password" value="${jdbc.password}"/&gt;
      ........
  &lt;/bean&gt;
  </code></pre>
  
  <p>How can I configure spring to set properties 
  <strong>verifyServerCertificate =true<br/>
  useSSL=true<br/>
  requireSSL=true"</strong><br/>
  Also is it possible to set <strong>keyStore and trustStore</strong> values in spring config file.</p>