basic
Properties are preceded by a question mark “?” and written as key=value pairs separated by the “&” symbol
jdbc connection
oracle (complex):
1. Connecting to SID
2. Connecting to Oracle service name
3. URL with tnsnames.ora entries
老版本 oracle
jdbc:oracle:thin:[<user>/<password>]@<host>[:<port>]:<SID>
jdbc:oracle:thin:[<user>/<password>]@//<host>[:<port>]/<service>
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=<host>)(PORT=<port>))(CONNECT_DATA=(SERVICE_NAME=<service>)))
protocol//[hosts][/database][?properties]
jdbc:xxxx://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
oracle.jdbc.driver.OracleDriver
jdbc:oracle:thin:[<user>/<password>]@<host>[:<port>]:<SID>
com.mysql.jdbc.Driver
jdbc:mysql://[host][,failoverhost...][:3306]/[database][?propertyName1][=propertyValue1][&propertyName2][=propertyValue2]
org.postgresql.Driver
jdbc:postgresql://host:5432/database?user=userName&password=pass
//special
com.microsoft.jdbc.sqlserver.SQLServerDriver
jdbc:microsoft:sqlserver://host:1433;databasename=name;user=yourUser;password=yourPwd
jdbc:sqlserver://[serverName[\instanceName][:portNumber]][;property=value[;property=value]]
example
oracle concept
SID: 唯一标识数据库(或者叫实例) ServiceName:别名,一实例可有多个
-- 均可用于连接
-- instance name
SELECT sys_context('USERENV','INSTANCE_NAME') FROM dual;
-- database name
select ora_database_name from dual;
-- SID
SELECT sys_context('USERENV', 'SID') FROM DUAL;
-- service name
select sys_context('USERENV','SERVICE_NAME') from dual;
-- 查询
select * from [userName][tableName]