I am trying to run a springexample. I have configured my .xml file as follows. I am using mysql as my DB, but I’m getting the error mentioned below
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="dataSource" destroy-method="close"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="org.hsqldb.jdbcDriver"/>
<property name="url" value="jdbc:hsqldb:hsql://127.0.0.1:3306"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
<bean id="forumDAO" class="com.vaannila.dao.ForumDAOImpl">
<property name="dataSource" ref="dataSource"/>
</bean>
</beans>
error
EDIT
now changed to
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://127.0.0.1:3306/test"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
Exception in thread “main”
org.springframework.jdbc.CannotGetJdbcConnectionException: Could not
get JDBC Connection; nested exception is
org.apache.commons.dbcp.SQLNestedException: Cannot create
PoolableConnectionFactory (socket creation error)
at org.springframework.jdbc.datasource.DataSourceUtils.getConnection(DataSourceUtils.java:82)
at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:572)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:786)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:842)
at org.springframework.jdbc.core.JdbcTemplate.update(JdbcTemplate.java:850)
at com.vaannila.dao.ForumDAOImpl.insertForum(ForumDAOImpl.java:29)
Your configuration file is setup for a HSQL database instead of a MySQL database.
Use:
You should also check, that you have the correct JDBC driver in your classpath.