不使用TNS直连数据库的三种方式

1、在当前目录下新建tnsnames.ora文件

如windows环境下,在C:UsersAdministrator目录下新建tnsnames.ora文件,内容如下:
test =(description=(address=(protocol=tcp)(host=192.168.0.1)(port=1521))(connect_data=(server=dedicated)(service_name=orcl)))
C:UsersAdministrator>sqlplus sys/rusky@test as sysdba;

SQL*Plus: Release 11.2.0.1.0 Production on 星期五 2月 13 00:03:51 2015

Copyright (c) 1982, 2010, Oracle. All rights reserved.

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


2、sqlplus连接时同时添加DESCTIPTION内容
C:UsersAdministrator>sqlplus SYS/rusky@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=rusky-PC)(port=1521))(CONNECT_DATA=(SID=orcl))) as sysdba;

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 12 23:56:33 2015

Copyright (c) 1982, 2010, Oracle. All rights reserved.

连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

3、使用IP、端口号、实例名直接连接
C:UsersAdministrator>sqlplus sys/rusky@127.0.0.1:1521/orcl as sysdba;

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 2月 12 23:58:24 2015

Copyright (c) 1982, 2010, Oracle. All rights reserved.


连接到:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

《FROM:http://blog.csdn.net/hhuck/article/details/5337764

=====================================================

JDBC连接ORACLE的三种方式:

格式一:jdbc:oracle:thin:@//<host>:<port>/<service_name>
格式二:jdbc:oracle:thin:@<host>:<port>:<SID> 
格式三:jdbc:oracle:thin:@<TNSName> 

原文地址:https://www.cnblogs.com/rusking/p/4289449.html