Defining Spring context configuration for database connection
This post helps in understanding the database configuration in spring in the form of bean.
The code snippet for this configuration is as below.
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${driverClassName}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</bean>
Some of the property values are configured in properties file.
The code snippet for properties file is as below.
jdbc.properties
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/database_name
username=admin
password=admin
This post helps in understanding the database configuration in spring in the form of bean.
The code snippet for this configuration is as below.
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="${driverClassName}" />
<property name="url" value="${url}" />
<property name="username" value="${username}" />
<property name="password" value="${password}" />
</bean>
Some of the property values are configured in properties file.
The code snippet for properties file is as below.
jdbc.properties
driverClassName=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/database_name
username=admin
password=admin
No comments:
Post a Comment