I am using mysql 5.0 and jdk1.6. My scenario is to get data from mysql using SSL.

private Connection connection;
String url ="jdbc:mysql://localhost/mysql?useSSL=true&requireSSL=true"
Class.forName("com.mysql.jdbc.Driver").newInstance ();
connection = DriverManager.getConnection(url, "root", "sa");

String url ="jdbc:mysql://localhost/mysql"
when i use the line given above, i got the output.

The data transfer should be in SSL
String url ="jdbc:mysql://localhost/mysql?useSSL=true&requireSSL=true"
when i use the line given above, i got the following error.

java.sql.SQLException: Communication link failure: javax.net.ssl.SSLHandshakeException, underlying cause: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target

** BEGIN NESTED EXCEPTION **

javax.net.ssl.SSLHandshakeException
MESSAGE: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target

STACKTRACE:

javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at com.sun.net.ssl.internal.ssl.Alerts.getSSLExceptio n(Alerts.java:174)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.fatal(S SLSocketImpl.java:1520)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:182)
at com.sun.net.ssl.internal.ssl.Handshaker.fatalSE(Ha ndshaker.java:176)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:975)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.proc essMessage(ClientHandshaker.java:123)
at com.sun.net.ssl.internal.ssl.Handshaker.processLoo p(Handshaker.java:511)
at com.sun.net.ssl.internal.ssl.Handshaker.process_re cord(Handshaker.java:449)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.readRec ord(SSLSocketImpl.java:817)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.perform InitialHandshake(SSLSocketImpl.java:1029)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHa ndshake(SSLSocketImpl.java:1056)
at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHa ndshake(SSLSocketImpl.java:1040)
at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:89 3)
at com.mysql.jdbc.Connection.createNewIO(Connection.j ava:1808)
at com.mysql.jdbc.Connection.<init>(Connection.java:4 52)
at com.mysql.jdbc.NonRegisteringDriver.connect(NonReg isteringDriver.java:411)
at java.sql.DriverManager.getConnection(DriverManager .java:582)
at java.sql.DriverManager.getConnection(DriverManager .java:185)
at com.comparegroup.web2vgl.model.vglmodel.VglModel.< init>(VglModel.java:56)
at com.comparegroup.web2vgl.model.vglmodel.VglProduct Model.<init>(VglProductModel.java:24)
at com.comparegroup.web2vgl.controller.Web2VglControl ler.getProductMap(Web2VglController.java:245)
at com.comparegroup.web2vgl.controller.Web2VglControl ler.execute(Web2VglController.java:142)
at com.comparegroup.web2vgl.controller.Web2VglControl ler.main(Web2VglController.java:81)
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:285)
at sun.security.validator.PKIXValidator.engineValidat e(PKIXValidator.java:191)
at sun.security.validator.Validator.validate(Validato r.java:218)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. validate(X509TrustManagerImpl.java:126)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:209)
at com.sun.net.ssl.internal.ssl.X509TrustManagerImpl. checkServerTrusted(X509TrustManagerImpl.java:249)
at com.sun.net.ssl.internal.ssl.ClientHandshaker.serv erCertificate(ClientHandshaker.java:954)
... 18 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderE xception: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder. engineBuild(SunCertPathBuilder.java:174)
at java.security.cert.CertPathBuilder.build(CertPathB uilder.java:238)
at sun.security.validator.PKIXValidator.doBuild(PKIXV alidator.java:280)
... 24 more


** END NESTED EXCEPTION **