org.springframework.beans.factory.BeanCreationException

Error when trying to work with database MySql using Spring
//org.springframework.beans.factory.BeanCreationException

Complete Error:

Solution:
Include MySQL JDBC Driver in your project path

Insert Update Delete using Spring (Spring + MySQL)

Insert Update Delete using Spring (Spring + MySQL)

Here is the code to insert, delete and update records using MySQL and Spring.
Code tested in NetBeans 8.0

Create Table in Database:

student.java

Studentdao.java

Spring-Config.xml
Include this code in Spring-Config.xml

Operations.java

 

 

javax.mail.MessagingException: Could not convert socket to TLS

javax.mail.MessagingException: Could not convert socket to TLS:

You may get this error when you are trying to send an e-mail using gmail server in java.

Complete Error:

Exception in thread “main” java.lang.RuntimeException: javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at checkmail.main(checkmail.java:64)
Caused by: javax.mail.MessagingException: Could not convert socket to TLS;
nested exception is:
javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1907)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:666)
at javax.mail.Service.connect(Service.java:367)
at javax.mail.Service.connect(Service.java:226)
at javax.mail.Service.connect(Service.java:175)
at javax.mail.Transport.send0(Transport.java:253)
at javax.mail.Transport.send(Transport.java:124)
at checkmail.main(checkmail.java:59)
Caused by: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.ssl.Alerts.getSSLException(Alerts.java:192)
at sun.security.ssl.SSLSocketImpl.fatal(SSLSocketImpl.java:1902)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:276)
at sun.security.ssl.Handshaker.fatalSE(Handshaker.java:270)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1338)
at sun.security.ssl.ClientHandshaker.processMessage(ClientHandshaker.java:154)
at sun.security.ssl.Handshaker.processLoop(Handshaker.java:868)
at sun.security.ssl.Handshaker.process_record(Handshaker.java:804)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1032)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1328)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1355)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1339)
at com.sun.mail.util.SocketFetcher.configureSSLSocket(SocketFetcher.java:528)
at com.sun.mail.util.SocketFetcher.startTLS(SocketFetcher.java:465)
at com.sun.mail.smtp.SMTPTransport.startTLS(SMTPTransport.java:1902)
… 7 more
Caused by: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:385)
at sun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:292)
at sun.security.validator.Validator.validate(Validator.java:260)
at sun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:326)
at sun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:231)
at sun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:126)
at sun.security.ssl.ClientHandshaker.serverCertificate(ClientHandshaker.java:1320)
… 17 more
Caused by: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
at sun.security.provider.certpath.SunCertPathBuilder.engineBuild(SunCertPathBuilder.java:196)
at java.security.cert.CertPathBuilder.build(CertPathBuilder.java:268)
at sun.security.validator.PKIXValidator.doBuild(PKIXValidator.java:380)
… 23 more
Java Result: 1

SOLUTION:
Add this line to your properties ,

props.put(“mail.smtp.ssl.trust”, “smtp.gmail.com”);

For Complete code for sending E-mail using gmail, Visit Here

How to draw chart in HTML

How to draw chart in HTML:

(Chart in HTML code)

A simple code to draw bar chart using HTML 5.

Requirements:
you are required for download RGraph.common.core.js(here) and RGraph.bar.js (here)
copy the code and paste it in notepad and save as RGraph.common.core.js and RGraph.bar.js

This code is tested in Netbeans, you can also view the video tutorial here Video Tutorial

 

YouTube Link: Video Tutorial

 

Send Email Using Gmail in Java

Send Email using Gmail in Java

Here is another code for sending email using Java.  My Previous code, it needs to have access to application-specific password(Sending Email Using Java). Here you just need to enter your email address and password.

Requirements:
1. you need mail.jar and activation.jar to be added to your project
2.  Sign in your gmail, go to Account–> Connected Apps and Sites –> Allow less secure apps: turn it ON