Spring Connect Database Motion connection properties for MySQL, Oracle, and SQL Server

Source: Internet
Author: User

The configuration file Applicationcontext.xml settings are as follows:

<?xml version= "1.0" encoding= "UTF-8"?>

< beans xmlns= "Http://www.springframework.org/schema/beans"

Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"

xsi:schemalocation= "Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/ Spring-beans-2.0.xsd ">

<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" >

<!--connection mysql-->

< property name= "Driverclassname" value= "Com.mysql.jdbc.Driver" ></property>

< property name= "url" value= "Jdbc:mysql://localhost:3306/mytest" ></property>

< property name= "username" value= "root" ></property>

< property name= "password" value= "root" ></property>

<!--Connect Oracle--

< property name= "Driverclassname" value= "Oracle.jdbc.driver.OracleDriver" ></property>

< property name= "url" value= "Jdbc:oracle:thin: @localhost: 1521:orcl" ></property>

< property name= "username" value= "Scott" ></property>

< property name= "password" value= "Tiger" ></property>

<!--connecting SQL server-->

< property name= "Driverclassname" value= "Com.microsoft.sqlserver.jdbc.SQLServerDriver" ></property>

< property name= "url" value= "Jdbc:sqlserver://localhost:1433;databasename=test" ></property>

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

< property name= "password" value= "123" ></property>

< property name= "maxactive" value= "" "></property>

< property name= "Maxidle" value= "+" ></property>

< property name= "maxwait" value= "></property>"

< property name= "Defaultautocommit" value= "true" ></property>

</bean>

<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >

< property name= "DataSource" ref= "DataSource" ></property>

< property name= "Hibernateproperties" >

< props>

<!--MySQL dialect---

< prop key= "Hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>

<!--Oracle's dialect---

<prop key= "Hibernate.dialect" >org.hibernate.dialect.OracleDialect</prop>

<!--the dialect of SQL Server---

<prop key= "Hibernate.dialect" >org.hibernate.dialect.SQLServerDialect</prop>

< prop key= "Hibernate.show_sql" >true</prop>

</props>

</property>

< property name= "Mappingresources" >

< list>

< value>com/test/bean/user.hbm.xml</value>

</list>

</property>

</bean>

<bean id= "Userdao" class= "Com.test.dao.impl.UserDAOImpl" scope= "singleton" >

< property name= "Sessionfactory" > < ref bean= "Sessionfactory"/>

</property>

</bean>

<bean id= "UserService" class= "Com.test.service.impl.UserServiceImpl" >

< property name= "Userdao" ref= "Userdao" ></property>

</bean>

<bean id= "saveuseraction" class= "Com.test.action.user.SaveUserAction" scope= "prototype" >

< property name= "service" ref= "UserService" ></property>

</bean>

<bean id= "listuseraction" class= "Com.test.action.user.ListUserAction" scope= "prototype" >

< property name= "service" ref= "UserService" ></property>

</bean>

<bean id= "removeuseraction" class= "Com.test.action.user.RemoveUserAction" scope= "prototype" >

< property name= "service" ref= "UserService" ></property>

</bean>

</beans>

Spring Connect Database Motion connection properties for MySQL, Oracle, and SQL Server

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.