我试图哄骗Oracle XE接受来自JDBC的连接。我使用XE安装中的ojdbc6.jar(还有ojdbc5和ojdbc6_g jars)。我已经尝试使用oracle.jdbc.OracleDriver和oracle.jdbc.driver.OracleDriver,驱动程序类已注册。我使用描述符:jdbc:oracle:thin:@localhost:1521:XE。
我也尝试以/ XE结束而不是:XE,我有时会看到它。还尝试了实际主机名Kaveri而不是localhost。
我可以使用sqlplus登录,数据库已打开,主服务和TNS监听器服务正在运行。
的listener.ora:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = E:\Data\OracleXE\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = E:\Data\OracleXE\app\oracle\product\11.2.0\server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = Kaveri)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
tsnames.ora:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = Kaveri)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
我得到了
java.util.concurrent.TimeoutException
at java.util.concurrent.FutureTask.get(Unknown Source)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.awaitConnection(OpenConnectionCommand.java:132)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand.access$100(OpenConnectionCommand.java:45)
at net.sourceforge.squirrel_sql.client.mainframe.action.OpenConnectionCommand$2.run(OpenConnectionCommand.java:115)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
或者使用我们自己的java程序
java.sql.SQLRecoverableException: IO Error: Socket read timed out
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:673)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:715)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:385)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:30)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:564)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
...
Caused by: oracle.net.ns.NetException: Socket read timed out
at oracle.net.ns.Packet.receive(Packet.java:350)
at oracle.net.ns.NSProtocolStream.negotiateConnection(NSProtocolStream.java:153)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:263)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1360)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:486)
... 39 more
lsnrctl似乎在一段时间后挂起了:
> lsnrctl status
LSNRCTL for 64-bit Windows: Version 11.2.0.2.0 - Production on 04-JUL-2017
17:29:09
Copyright (c) 1991, 2014, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
TNS-12560: TNS:protocol adapter error
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=Kaveri)(PORT=1521)))
这是Oracle XE在Windows 10上的“重新安装”。为了避免疑问,我也关闭了防火墙,没有效果(我希望!)。
如何调试连接到Oracle?谢谢。
更新:当我将TNSListener列为正在运行时,我正在撒谎 - 或者说是Windows - 情况实际上是“本地计算机上的OracleXETNSListener服务已启动然后停止......”
答案 0 :(得分:0)
如果我在配置文件中使用localhost而不是Kaveri,那么监听器就会保持正常状态(为什么,因为主机名是Kaveri ..?)