VisualBuilder
  Home > Java > Tutorials > Spring data access overview - Spring tutorial
Tell a friend
Link to us
Total Members
      Members: 84648
     
Sitemap Forum Chat
Home
Spring Tutorial Tutorial Home
1 . What is Spring?
2 . What are the main concepts for Spring?
3 . Why use Spring?
4 . Spring architecture
5 . Installing Spring
6 . Where is Spring in our applications?
7 . How to create a bean descriptor XML file?
8 . Spring and Struts
9 . Spring and Struts - Hello World example
10 . Spring data access overview
11 . Spring data access example using Hibernate
12 . Next Steps
 
Java Group Home
Java Discussion (273)
Java Members (27593)
Java Resources
Java Source Code (1095)
Java Articles (5)
Java Blogs
Java Jobs
Java Components (84)
Java Books
Java Websites (126)
Java News (103)
Java Q & A (114)
- Java Ask Question
- Java Questions
- Java Unanswered Questions
 
GROUPS
.NET
ASP.NET
.NET
C#
ASP
Visual Basic
Java
Java
JSP
EJB
Other
Delphi
C++
Ajax
UML
JavaScript
PHP
Web Design
Web Hosting
SQL Server
Oracle
Project Management
More Groups

 
LEARNING CENTER
TUTORIALS
.NET
.NET Tutorial
ASP Tutorial
ASP.NET Database Tutorial
ASP.NET Development Tips
ASP.Net Security,Internationalisation And Deployment
ASP.NET Server Controls Tips
ASP.NET Tutorial
C Sharp Tutorial
Web Development
Flex Tutorial
HTML Tutorial
Learn AJAX Tutorial
PHP Tutorial
Software Development
Database Tutorial
SQL Tutorial
UML Tutorial
Java
Ant Tutorial
EJB 3 Tutorial
Hibernate Tutorial
Java Tutorial
Java Web Component Tutorial
Java XML Tutorial
JDBC Tutorial
JDK1.5 Tutorial
JSF Tutorial
JSP And J2EE Design Tutorial
JSP Tutorial
Spring Tutorial
Struts Tutorial

RESOURCES
Q & A (436 )
Source Code (3275 )
Articles (11 )
Components (1589 )
News (888 )
Websites (1207 )

SUBMISSIONS
Submit Article
Submit Website
Submit News
Submit Source Code
Submit Component

COMMUNITY
Members Directory
Discussion Forum
Chat

SITE
About Us
Sitemap
Search
Contact Us
Link To Us
Feedback
Tell a Friend
Partners
Advertise


Java spring Tutorial
 Spring data access overview
  << Prev: Spring and Struts - Hello World example Next: Spring data access example using Hibernate >>

Spring provides a unique data access abstraction,including a simple and productive JDBC framework.


Spring data access architecture also integrates with TopLink,Hibernate,JDO,and other O/R mapping solutions



In the figure,data accessing in an application is included in a separate layer called DAO


Spring DAO Support classes provide ability to acquire DAO implementations. They also include the DAO classes extended from DAOSupport to integrate to other database broker system. Each DAO class is used as a bridge to integrate to a special database broker system,as in the figure below:



DataSources
In order to execute any JDBC operation on a database,you need a Connection. In Spring DAO,Connection objects are obtained through a DataSource.


DataSource contains database accessing information and is assigned to Spring DAO Support classes before using these DAO classes to operate database


DataSourse is declared as a bean in Spring descriptor XML file,for example:


JNDIObjectFactoryBean as DataSource to access via JNDI:

<bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
<property name="jndiName">
<value>java:comp/env/jdbc/myDatasource</value>
</property>
</bean>



DriverManagerDataSource as DataSource to access via JDBC:


<bean id="myDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">


 <property name="driverClassName">
 <value>com.microsoft.jdbc.sqlserver.SQLServerDriver</value>
</property>


         <property name="url">
<value>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=Hibernate_books</value>
</property>


         <property name="username"><value>sa</value></property>
         <property name="password"><value>sa</value></property>
</bean>


Using DataSource
DataSource is assigned to DAO Support classes through different ways,base on kind of database broker system


Content of the Spring XML descriptor bean files show the way of how a DataSource is assigned to DAO Support. Following is an example for Hibernate:


With Hibernate,LocalSessionFactoryBean is to store DataSource. The LocalSessionFactoryBean then is passed into Hibernate DAO Integration in sessionFactory property. In this case,BookService class is a direct subclass of Hibernate DAO Integration.


  << Prev: Spring and Struts - Hello World example Next: Spring data access example using Hibernate >>
Java Spring Tutorial Home
Give feedback and win a prize.

 
   Printer Friendly
   Email to a friend
   Add to my Favourites    
  Download PDF version
   Report Bad Submissions
   Submit Feedback
 
  Delicious   Digg   Technorati   Blink   Furl   Reddit   Newsvine   Google Click each image to add
this page to each site.
 
 
Welcome Guest Signup
MEMBER'S PANEL
EMAIL
PASSWORD
Forgot your password?
New User? Click Here!
 
Resend Activation Email!
 
SEARCH
 
 
LINKS
MSN
Video Surveillance
Skype vs. sipcall
Gift to Pakistan
 
ADVERTISEMENT
 
PARTNER LIST

More
 
 
 

Home | Login | About Us | Contact Us | Privacy Policy | Advertising