Skip to content

Commit 47e6077

Browse files
authored
Merge pull request eugenp#6973 from amit2103/BAEL-14322
[BAEL-14322] - Updated Spring JDBC Article
2 parents aecfb01 + 560e0f7 commit 47e6077

File tree

12 files changed

+41
-1
lines changed

12 files changed

+41
-1
lines changed

persistence-modules/spring-persistence-simple/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Transactions with Spring and JPA](https://www.baeldung.com/transaction-configuration-with-jpa-and-spring)
1212
- [Introduction to Spring Data JPA](http://www.baeldung.com/the-persistence-layer-with-spring-data-jpa)
1313
- [Spring Data JPA @Query](http://www.baeldung.com/spring-data-jpa-query)
14+
- [Spring JDBC](https://www.baeldung.com/spring-jdbc-jdbctemplate)
1415

1516

1617
### Eclipse Config

persistence-modules/spring-persistence-simple/pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@
108108
<artifactId>querydsl-apt</artifactId>
109109
<version>${querydsl.version}</version>
110110
</dependency>
111+
<dependency>
112+
<groupId>org.hsqldb</groupId>
113+
<artifactId>hsqldb</artifactId>
114+
<version>${hsqldb.version}</version>
115+
<scope>test</scope>
116+
</dependency>
111117
</dependencies>
112118

113119
<build>
@@ -150,6 +156,7 @@
150156
<tomcat-dbcp.version>9.0.0.M26</tomcat-dbcp.version>
151157
<jta.version>1.1</jta.version>
152158
<querydsl.version>4.2.1</querydsl.version>
159+
<hsqldb.version>2.4.1</hsqldb.version>
153160

154161
<!-- util -->
155162
<guava.version>21.0</guava.version>

spring-all/src/main/java/org/baeldung/jdbc/CustomSQLErrorCodeTranslator.java renamed to persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/jdbc/CustomSQLErrorCodeTranslator.java

File renamed without changes.

spring-all/src/main/java/org/baeldung/jdbc/Employee.java renamed to persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/jdbc/Employee.java

File renamed without changes.

spring-all/src/main/java/org/baeldung/jdbc/EmployeeDAO.java renamed to persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/jdbc/EmployeeDAO.java

File renamed without changes.

spring-all/src/main/java/org/baeldung/jdbc/EmployeeRowMapper.java renamed to persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/jdbc/EmployeeRowMapper.java

File renamed without changes.

spring-all/src/main/java/org/baeldung/jdbc/config/SpringJdbcConfig.java renamed to persistence-modules/spring-persistence-simple/src/main/java/org/baeldung/jdbc/config/SpringJdbcConfig.java

File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE TABLE EMPLOYEE
2+
(
3+
ID int NOT NULL PRIMARY KEY,
4+
FIRST_NAME varchar(255),
5+
LAST_NAME varchar(255),
6+
ADDRESS varchar(255),
7+
);
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
3+
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
4+
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
5+
>
6+
7+
<bean id="employeeDao" class="org.baeldung.jdbc.EmployeeDAO">
8+
<property name="dataSource" ref="dataSource"/>
9+
</bean>
10+
11+
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
12+
<property name="driverClassName" value="${jdbc.driverClassName}"/>
13+
<property name="url" value="${jdbc.url}"/>
14+
<property name="username" value="${jdbc.username}"/>
15+
<property name="password" value="${jdbc.password}"/>
16+
</bean>
17+
18+
<context:property-placeholder location="jdbc.properties"/>
19+
</beans>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
INSERT INTO EMPLOYEE VALUES (1, 'James', 'Gosling', 'Canada');
2+
3+
INSERT INTO EMPLOYEE VALUES (2, 'Donald', 'Knuth', 'USA');
4+
5+
INSERT INTO EMPLOYEE VALUES (3, 'Linus', 'Torvalds', 'Finland');
6+
7+
INSERT INTO EMPLOYEE VALUES (4, 'Dennis', 'Ritchie', 'USA');

0 commit comments

Comments
 (0)