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

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.