Read the guide: This article focuses on how to configure the JDBC connection in the spring framework to connect to Oracle, MYSQL, SQL Server.
The principle is as follows:
First, the Guide package
The jar package required to connect the oracle11g: Ojdbc6.jar
The jar package required to connect the mysql5.1: Mysql-connector-java-5.1.12-bin.jar
The jar package required to connect the sqlserver2008: Sqljdbc4.jar
Note: The jar package version corresponds to the software version
Data source Configuration Required Package: Tomcat-jdbc-7.0.61.jar
Tomcat-juli-7.0.61.jar
The tomcat version used here is 7.0.61
Second, properties and configuration files
Jdbc.properties
MySQL database jdbc.driver=com.mysql.jdbc.driverjdbc.url=jdbc:mysql://localhost:3306/testjdbc.username= Rootjdbc.password=root#oracle Database jdbc.driver=oracle.jdbc.driver.oracledriverjdbc.url=jdbc:oracle:thin:@ Localhost:1521/orcl#jdbc.url=jdbc:oracle:thin: @localhost: 1521:orcljdbc.username=rootjdbc.password=oracle# SQL Server Database jdbc.driver=com.microsoft.sqlserver.jdbc.sqlserverdriverjdbc.url=jdbc:microsoft.sqlserver:// 127.0.0.1:1433;databasename=zhidaojdbc.username=rootjdbc.password=oracle
Applicationcontext.xml
<!--data source configuration, using the Tomcat JDBC Pool - <BeanID= "DataSource"class= "Org.apache.tomcat.jdbc.pool.DataSource"Destroy-method= "Close"> <!--Connection Info - < Propertyname= "Driverclassname"value= "${jdbc.driver}"/> < Propertyname= "url"value= "${jdbc.url}"/> < Propertyname= "username"value= "${jdbc.username}"/> < Propertyname= "Password"value= "${jdbc.password}"/></Bean>
You can see the followingarticle: 52957968
Spring configures JDBC Connection orcale, MYSQL, SQL Server