You should configure dataSource
as a bean, each line you wrote inside should be defined as a property
. An example:
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/myschema" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
As you can see from the example, you can use different drivers - depends on the DB you're connecting to.
Another example:
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost:3306/myschema" />
<property name="username" value="root" />
<property name="password" value="password" />
</bean>
IMPORTANT:
from Spring docs about DriverManagerDataSource
:
This class is not an actual connection pool; it does not actually pool
Connections. It just serves as simple replacement for a full-blown
connection pool, implementing the same standard interface, but
creating new Connections on every call.
If you need a "real" connection pool outside of a J2EE container,
consider Apache's Jakarta Commons DBCP or C3P0. Commons DBCP's
BasicDataSource and C3P0's ComboPooledDataSource are full connection
pool beans, supporting the same basic properties as this class plus
specific settings (such as minimal/maximal pool size etc).
I recommend on reading the following good introduction to JDBC