Configuration of data sources in spring and JDBC driver packages for various databases (Oracle, MySQL, SQL Server, etc.)

Source: Internet
Author: User
Tags db2 informix postgresql sybase

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.)

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.