diff options
| author | Kamal Wickramanayake <kamal@inbox.lk> | 2026-04-25 21:53:33 +0530 |
|---|---|---|
| committer | Kamal Wickramanayake <kamal@inbox.lk> | 2026-04-25 21:53:33 +0530 |
| commit | 4afcff940551079617e8f4116e52bb0ef9df7fcc (patch) | |
| tree | cbaed6a2a53c7d032bfafaa38b94e4fc607f3e76 /spring-framework/07-user-jdbc-ds-transaction/src/main/resources | |
| parent | 7b08f1155e1cb8bf263c3570eeb119970407a037 (diff) | |
Added Spring Framework sample code
Diffstat (limited to 'spring-framework/07-user-jdbc-ds-transaction/src/main/resources')
2 files changed, 48 insertions, 0 deletions
diff --git a/spring-framework/07-user-jdbc-ds-transaction/src/main/resources/META-INF/spring/applicationContext.xml b/spring-framework/07-user-jdbc-ds-transaction/src/main/resources/META-INF/spring/applicationContext.xml new file mode 100644 index 0000000..9b85cd3 --- /dev/null +++ b/spring-framework/07-user-jdbc-ds-transaction/src/main/resources/META-INF/spring/applicationContext.xml @@ -0,0 +1,39 @@ +<?xml version="1.0" encoding="UTF-8"?> +<beans xmlns="http://www.springframework.org/schema/beans" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xmlns:jdbc="http://www.springframework.org/schema/jdbc" + xmlns:context="http://www.springframework.org/schema/context" + xsi:schemaLocation="http://www.springframework.org/schema/beans + http://www.springframework.org/schema/beans/spring-beans.xsd + http://www.springframework.org/schema/jdbc + http://www.springframework.org/schema/jdbc/spring-jdbc.xsd + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context.xsd"> + + <context:property-placeholder location="classpath:META-INF/spring/jdbc.properties"/> + + <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close" > + <property name="driverClassName" value="${jdbc.driverClassName}"/> + <property name="url" value="${jdbc.url}"/> + <property name="username" value="${jdbc.username}"/> + <property name="password" value="${jdbc.password}"/> + </bean> + + <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> + <property name="dataSource" ref="dataSource"/> + </bean> + + <bean id="userDAO" class="com.example.fp.dao.jdbc.JDBCUserDAO" > + <property name="dataSource" ref="dataSource"/> + </bean> + + <bean id="userManagerWithNoTransactionSupport" class="com.example.fp.UserManagerImpl"> + <property name="userDAO" ref="userDAO"/> + </bean> + + <bean id="userManager" class="com.example.fp.tx.TxUserManager"> + <property name="userManager" ref="userManagerWithNoTransactionSupport"/> + <property name="txManager" ref="txManager"/> + </bean> + +</beans>
\ No newline at end of file diff --git a/spring-framework/07-user-jdbc-ds-transaction/src/main/resources/META-INF/spring/jdbc.properties b/spring-framework/07-user-jdbc-ds-transaction/src/main/resources/META-INF/spring/jdbc.properties new file mode 100644 index 0000000..83220af --- /dev/null +++ b/spring-framework/07-user-jdbc-ds-transaction/src/main/resources/META-INF/spring/jdbc.properties @@ -0,0 +1,9 @@ +jdbc.driverClassName=com.mysql.cj.jdbc.Driver +#jdbc.url=jdbc:mysql://localhost/bankdb?useSSL=false +#jdbc.url=jdbc:mysql://localhost/bankdb?useLegacyDatetimeCode=false&serverTimezone=UTC +jdbc.url=jdbc:mysql://localhost/bankdb?serverTimezone=Asia/Colombo +jdbc.username=bankdbuser +jdbc.password=abc123 + +#jdbc.driverClassName=org.postgresql.Driver +#jdbc.url=jdbc:postgresql://localhost/bank |
