When developing a database-based application system, you must configure the data source in the project to connect to the database for database operations. The methods for configuring data sources for different databases are basically the same. The difference is that the JDBC driver classes and connection URLs of different databases and the corresponding database usernames and passwords are different. The following lists the configuration of common database data sources and corresponding JDBC driver packages.
1. Data source configuration format in spring
<Bean id = "datasource" class = "org. Apache. commons. DBCP. basicdatasource" Destroy-method = "close">
<Property name = "driverclassname" value = ""/>
<Property name = "url" value = ""/>
<Property name = "username" value = ""/>
<Property name = "password" value = ""/>
</Bean>
The data source defined in the implementation solution of the DBCP open source database of Jakarta is used here.
2. configuration parameters for various databases and their data sources
| Database |
Driver |
URL |
Username |
Password |
| Oracle |
Oracle. JDBC. Driver. oracledriver |
JDBC: oracle: thin: @ localhost: 1521: orcl |
Scott |
Tiger |
| DB2 |
Com. IBM. db2.jdbc. App. db2driver |
JDBC: DB2: // localhost: 5000/testdb |
Root |
Admin |
| SQL Server |
Com. Microsoft. JDBC. sqlserver . Sqlserverdriver |
JDBC. Microsoft: sqlserver: // localhost: 1433; Databasename = testdb |
Root |
Admin |
| Sybase |
Com. Sybase. JDBC. sybdriver |
JDBC: Sybase: TDS: localhost: 5007/testdb |
|
|
| Informix |
Com. Informix. JDBC. ifxdriver |
JDBC: informixsqli: // 123.45.67.89: 1533/mydb: Informixserver = myserver |
|
|
| MySQL |
Com. MySQL. JDBC. Driver |
JDBC: mysql: // localhost: 3306/testdb |
|
|
| PostgreSQL |
Org. PostgreSQL. Driver |
JDBC: PostgreSQL: // localhost/testdb |
|
|
| HSQLDB |
Org. HSQLDB. jdbcdriver |
JDBC: HSQLDB: hsql: // llocalhost: 9902 |
|
|
For the rest of the work, you only need to import the corresponding database driver.
Basicdatasource data source configuration and Data