Spring Tutorial

❮ Previous Next ❯

Spring JDBC Introduction

Hi friends, focus to this concept before going to spring JDBC. Here i am presenting the detail introduction to spring JDBC.

We know that we use JDBC technology for persistency purpose, that means connecting with database and performing some operations like insert, update, delete etc. Without using JDBC we cannot able to connect with databases.

But there are some difficulties if a java programmer is directly working with JDBC which is as follows:

To eliminate these above problems, Spring framework has provided one abstraction layer on top of existing JDBC called Spring-JDBC. Here programmers will work with this abstraction layer and that layer will internally uses JDBC technology. So spring-JDBC layer will take cares about connection management and error managements, and programmers will concentrate on their logics.

There is an exception translator provided by spring framework which translates the checked exceptions to un-checked exceptions of spring type and finally the un-checked exceptions are thrown to java programmer. Another advantage is while working with spring-JDBC, the programmer is not required to open and close the database connection, because that will be taken care by the spring framework.

There are two ways to get connection with database like,

Spring framework uses DataSource interface to obtain the connection with database internally, there are two implementation classes and we can use any one of the following classes of DataSource interface.

Here DriverManagerDataSource is given by spring framework and it is equal to DriverManager class, spring framework internally opens a new connection and closes the connection for each operation done on the database.

BasicDataSource is given the apache, and this is better than DriverManagerDataSource because BasicDataSource having inbuilt connection pooling implementation.

In spring configuration file, the following 4 properties that we have to write to get connection with database. The code is like:

<bean id="id2" class="org.springframework.datasource.DriverManagerDataSource">
<bean id="id2" class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName" value=" " />
<property name="url" value=" " />
<property name="username" value=" " />
<property name=password" value=" " />

❮ Previous Next ❯

Follow Us


Popular Links

Contact Us

address Plot No-741,2ND Floor
Opp. Bhagabati Temple,Jayadev Vihar
      Email: info@silantechnology.com
      Phone: 0674-2361252
39877, sundale dr, apt#101, Fremont, California 94538, USA
       Phone: +1(262)388-7619

facebook twitter google linked in

© 2018 Silan Technology. All Rights Reserved