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 method of configuring data sources for different databases is largely the same. The only difference is that the JDBC driver class and connection URL for the different databases and the corresponding database username and passwords are different. The following is a list of database data source configurations and corresponding JDBC driver packages for databases that are used frequently in 8.
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
============================================================================================
Configuration of data sources in spring and JDBC driver packages for various databases (Oracle, MySQL, SQL Server, etc.)