DataSource in hibernate.

DataSource in hibernate.

What is DataSource in hibernate?

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
ModuleNotFoundError: No module named 'datasource'
ModuleNotFoundError: No module named 'datasource'  Hi, My Python... 'datasource' How to remove the ModuleNotFoundError: No module named 'datasource' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'datasource'
ModuleNotFoundError: No module named 'datasource'  Hi, My Python... 'datasource' How to remove the ModuleNotFoundError: No module named 'datasource' error? Thanks   Hi, In your python environment you
Artifacts of excalibur-datasource
List of Artifacts of excalibur-datasource maven depenency
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 >> 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
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
ModuleNotFoundError: No module named 'dw-datasource'
ModuleNotFoundError: No module named 'dw-datasource'  Hi, My... 'dw-datasource' How to remove the ModuleNotFoundError: No module named 'dw-datasource' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Graphviz-Datasource'
ModuleNotFoundError: No module named 'Graphviz-Datasource'  Hi, My... named 'Graphviz-Datasource' How to remove the ModuleNotFoundError: No module named 'Graphviz-Datasource' error? Thanks   Hi
ModuleNotFoundError: No module named 'vector-datasource'
ModuleNotFoundError: No module named 'vector-datasource'  Hi, My... named 'vector-datasource' How to remove the ModuleNotFoundError: No module named 'vector-datasource' error? Thanks   Hi, In your
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
Version of excalibur-datasource>excalibur-datasource-vm14 dependency
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
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
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
HIBERNATE
HIBERNATE   What is difference between Jdbc and Hibernate
hibernate
hibernate  what is hibernate listeners
hibernate
hibernate  what is hibernate flow
hibernate
hibernate  what is hibernate why we use
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  how to use pagination concept in Hibernate
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application
hibernate
hibernate   I want to learn how to use hibernate framework in web application . for storing database in our application

Ads