When you work with JDBC application, by default the auto commit is set to true, after the transaction is completed all the transactions are committed to the database. When it is set as true, you can not explicitly call the commit method. If you call the connection.commit() method, then the below exception will be thrown.
INFO: Loaded JDBC driver: com.mysql.jdbc.Driver Exception in thread "main" java.lang.RuntimeException: java.sql.SQLException: Can't call commit when autocommit=true at javabeat.net.spring.core.Country.insertCountryName(Country.java:54) at javabeat.net.spring.core.SpringStandAloneExample.main(SpringStandAloneExample.java:11) Caused by: java.sql.SQLException: Can't call commit when autocommit=true at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:914) at com.mysql.jdbc.Connection.commit(Connection.java:2275) at javabeat.net.spring.core.Country.insertCountryName(Country.java:51)