Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

DataSource in hibernate.

Ads

 
 

Share on Google+Share on Google+

ratna rathor
DataSource in hibernate.
1 Answer(s)      5 years and 2 months ago
Posted in : Hibernate

What is DataSource in hibernate?

Ads
View Answers

May 30, 2012 at 7:21 PM


Generally, in spring hibernate integration or struts hibernate integration we set data source class for integration. Here is a example of spring hibernate integration- dispatcher-servelet.xml configration file.This is saved in WEB-INF -

<?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:context="http://www.springframework.org/schema/context"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">

    <!-- Enable annotation driven controllers, validation etc... -->
    <!-- Spring Web Mapping -->
    <context:component-scan base-package="net.roseindia.controller" />


    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix">
            <value>/WEB-INF/views/</value>
        </property>
        <property name="suffix">
            <value>.jsp</value>
        </property>
    </bean>

    <!-- Spring Web Mapping End-->

    <!-- Spring Hibernate Mapping -->

    <bean id="dataSource"
        class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url" value="jdbc:mysql://localhost:3306/spring_hibernate" />
        <property name="username" value="root" />
        <property name="password" value="root" />
    </bean>

    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="annotatedClasses">
            <list>
                <value>net.roseindia.domain.Student</value>
            </list>
        </property>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.HSQLDialect</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">none</prop>
            </props>
        </property>
    </bean>

    <!-- Spring Message Resources Mapping End-->
    <bean id="studentDao" class="net.roseindia.dao.daoImpl.StudentDaoImpl">
        <property name="sessionFactory" ref="sessionFactory" />
    </bean>
<bean id="service" class="net.roseindia.services.impl.StudentServiceImpl">
        <property name="studentDao" ref="studentDao" />
    </bean>


</beans>

Ads









Related Tutorials/Questions & Answers:
DataSource in hibernate.
DataSource in hibernate.  What is DataSource in hibernate?   Generally, in spring hibernate integration or struts hibernate integration we set data source class for integration. Here is a example of spring hibernate
hibernate tomcat
In this section, you will learn about Hibernate datasource configuration in Tomcat
Advertisements
hibernate jndi
In this section, you will learn about configuring hibernate to connect to database via JNDI datasource
Version of excalibur-datasource>excalibur-datasource dependency
List of Version of excalibur-datasource>excalibur-datasource dependency
Version of excalibur-datasource>excalibur-datasource-cluster dependency
List of Version of excalibur-datasource>excalibur-datasource-cluster dependency
Version of excalibur-datasource>excalibur-datasource-ids dependency
List of Version of excalibur-datasource>excalibur-datasource-ids dependency
datasource in jsp using struts
datasource in jsp using struts  how to get the datasource object in jsp.datasource is configured in struts-config.xml
Datasource - JSP-Servlet
Datasource   in web.xml datasource com.zetcode.DataSourceExample /DataSource datasource in index.jsp when i deploy the application i am getting
Artifacts of excalibur-datasource
List of Artifacts of excalibur-datasource maven depenency
property datasource required - Spring
property datasource required  Hi I am using java springs I am using mysql as backend I am getting one error when i compile the application.property datasource required. This is my dispatcher-servlet.xml
Maven Dependency excalibur-datasource >> 1.0
You should include the dependency code given in this page to add Maven Dependency of excalibur-datasource >> excalibur-datasource version1.0 in your project
Maven Dependency excalibur-datasource >> 1.1.1
You should include the dependency code given in this page to add Maven Dependency of excalibur-datasource >> excalibur-datasource version1.1.1 in your project
Maven Dependency excalibur-datasource >> 1.2.0
You should include the dependency code given in this page to add Maven Dependency of excalibur-datasource >> excalibur-datasource version1.2.0 in your project
Maven Dependency excalibur-datasource >> 2.1
You should include the dependency code given in this page to add Maven Dependency of excalibur-datasource >> excalibur-datasource version2.1 in your project
Managing Datasource in struts Application
Managing Datasource in struts Application  Hi i need to know how to do set up of Oracle data base with struts using Data source.I have defined datasource in struts-config.xml as data-sources> <data-source type
configure Datasource in enterprise application - EJB
configure Datasource in enterprise application  I wanted to know that how can configure the DataSource in the Enterprise Application.Thanks Rohit Chauhan  which type of IDE u r using???If NetBeans ..Then i have
Registering DataSource with JNDI
; } Registering The DataSource With JNDI Java Naming Directory Interface (JNDI... for objects for their associating attributes etc. An Example of DataSource...(); ConnectionPoolDataSource dataSource = new MysqlConnectionPoolDataSource
JDBC DataSource Example
; } JDBC DataSource Example You can establish a connection to a database either using DriverManager class or DataSource interface. JDBC DataSource... application program. DataSource object increases the application portability
Maven Dependency excalibur-datasource-cluster >> 1.1.1a
You should include the dependency code given in this page to add Maven Dependency of excalibur-datasource >> excalibur-datasource-cluster version1.1.1a in your project
Maven Dependency excalibur-datasource-ids >> 1.1.1a
You should include the dependency code given in this page to add Maven Dependency of excalibur-datasource >> excalibur-datasource-ids version1.1.1a in your project
How to create datasource and connectionpool in websphere 6.0 - Java Beginners
How to create datasource and connectionpool in websphere 6.0  how to create datasource and connection pool in websphere version 6.0? and give complete example on connectionpool datasource
HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate
hibernate
hibernate  what is hibernate listeners
hibernate
hibernate  what is hibernate flow
hibernate
hibernate  how to uses optional column in hibernate
hibernate
hibernate  please give me the link where i can freely download hibernate software(with dependencies)   Learn hibernate, if you want to learn hibernate, please visit the following link: Hibernate Tutorials
Hibernate
Hibernate  hibernate delete query execution
hibernate
hibernate  what is hibernate why we use
Hibernate
Hibernate  how to use pagination concept in Hibernate