我一直在使用oracle数据库编写Java应用程序。 最初,我的连接网址是
jdbc:oracle:thin:@localhost:1521:XE
它一直运行良好。我想更改自己的URL,以便可以从任何便携式计算机连接到数据库。 我将连接网址更改为
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS = (PROTOCOL = TCP)(HOST = LAPTOP-3ME2EPSM)(PORT = 1521))(CONNECT_DATA = (SERVER = DEDICATED)(SERVICE_NAME = XE)))
这是我在Internet上找到的格式。更改连接URL后,我无法再连接到数据库。没有错误。该程序将永远保持运行状态,并且连接永远不会结束。
下面是我的listener.ora:
DEFAULT_SERVICE_LISTENER = XE
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = some local address)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:some local address")
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = LAPTOP-3ME2EPSM)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
这是我的tnsnames.ora:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = LAPTOP-3ME2EPSM)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
LISTENER_XE =
(ADDRESS = (PROTOCOL = TCP)(HOST = LAPTOP-3ME2EPSM)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
XEPDB1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = LAPTOP-3ME2EPSM)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XEPDB1)
)
)
答案 0 :(得分:0)
检查是否可以使用SQL Plus使用URL进行连接?您的数据库可能是本地数据库。