一旦連接(並且不是系統管理員),您可以從數據庫創建所需的所需字符串。
也許看起來很愚蠢,但從任何實用程序查詢相同的參數將花費很長時間進行編程。
SELECT
USER
||'/******@'
|| sys_context('userenv','db_name') as simpleconnection
,'jdbc:oracle:thin:'
||USER
||'/******@'
|| sys_context('userenv', 'server_host') --host
|| ':'
|| sys_context('USERENV', 'SID') --port
|| ':'
|| sys_context('userenv','db_name') AS "Oracle Eight" --SID
,'jdbc:oracle:thin:'
||USER
||'/******@'
||sys_context('userenv', 'server_host') --host
||':'
||sys_context('USERENV', 'SID') --port
||'/'
|| sys_context('userenv','service_name') AS "host form"
,'jdbc:oracle:thin:'
||USER
||'/******@'
||sys_context('userenv', 'ip_address') --ip
||':'
||sys_context('USERENV', 'SID') --port
||'/'
|| sys_context('userenv','service_name') AS "IP form"
,'jdbc:oracle:thin:'
||USER
||'/******@(description=(address=(host='
||sys_context('userenv', 'server_host') --host
||')(protocol='
||sys_context('userenv', 'network_protocol') --protocol
||')(port='
||sys_context('USERENV', 'SID') --port
||'))(connect_data=(service_name='
|| sys_context('userenv','service_name') --service name
||')(server='
||sys_context('userenv','host') --name of the machine
||')))' AS "TNS form"
FROM dual d;
BTW它不被認爲是很好的做法,把登錄憑據到連接字符串,因爲缺乏可讀性,你可以將其添加爲參數。