Configuration of data sources in spring and JDBC driver packages for various databases (Oracle, MySQL, SQL Server, etc.)
When developing a database-based application system, you need to configure the data source in your project to obtain a database connection for the operation of the database. The methods for configuring data sources for different databases are largely the same, except that the JDBC driver classes and connection URLs for different databases are different from the corresponding database user names and passwords. The database data source configuration and the corresponding JDBC driver package for the databases that are commonly used in 8 are listed below.
1. Data source configuration format in spring
<bean id= "DataSource" class= "Org.apache.commons.dbcp.BasicDataSource" destroy-method= "Close" >
<property name= "Driverclassname" value= "${jdbc.driverclassname}"/>
<property name= "url" value= "${jdbc.url}"/>
<property name= "username" value= "${jdbc.username}"/>
<property name= "Password" value= "${jdbc.password}"/>
</bean>
2. Various databases and their data source configuration parameters
Database Oracle
================================================================================================
Driver Jdbc.driverclassname=oracle.jdbc.driver.oracledriver
URL Jdbc.url=jdbc:oracle:thin: @localhost: 1521:ORCL
User name Jdbc.username= Connection name
Password jdbc.password= connection password
================================================================================================
Mysql Database
================================================================================================
Jdbc.driverclassname=com.mysql.jdbc.driver
jdbc.url=jdbc\:mysql\://localhost\:3306/database name? useunicode\=true&characterencoding\=utf-8
Jdbc.username= Connection Name
jdbc.password= Connection Password
================================================================================================
Database SQL Server
================================================================================================
Driver Com.microsoft.jdbc.sqlserver.SQLServerDriver
URL Jdbc.microsoft:sqlserver://localhost:1433;databasename=testdb
================================================================================================
Database PostgreSQL
================================================================================================
Driver Org.postgresql.Driver
URL Jdbc:postgresql://localhost/testdb
================================================================================================
Database HSQLDB
================================================================================================
Driver Org.hsqldb.jdbcDriver
URL jdbc:hsqldb:hsql://llocalhost:9902
================================================================================================
Database DB2
================================================================================================
Driver Com.ibm.db2.jdbc.app.DB2Driver
URL Jdbc:db2://localhost:5000/testdb
================================================================================================
Database Sybase
================================================================================================
Driver Com.sybase.jdbc.SybDriver
URL Jdbc:sybase:tds:localhost:5007/testdb
================================================================================================
Database Informix
================================================================================================
Driver Com.informix.jdbc.IfxDriver
URL Jdbc:informixsqli://123.45.67.89:1533/mydb:informixserver=myserver
============================================================================================
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Configuration of data sources in spring and JDBC driver packages for various databases (Oracle, MySQL, SQL Server, etc.)