一旦连接(并且没有系统管理员),您就可以从数据库中创建所需的字符串。
也许这看起来很愚蠢,但是从任何实用程序查询相同的参数将花费您很长时间来编程。
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;
顺便说一句,将登录凭据放入连接字符串不是一个好习惯,因为缺乏可读性,您可以将它们添加为参数。