您好我有一个文件上传应用程序,它将excel文件上传到我们的oracle数据库。
这是我连接数据库时的代码:
Class.forName("oracle.jdbc.driver.OracleDriver");
String serverName = null;
String sid = null;
String portNumber = "1521";
String username = "*****";
String password = "*****";
serverName = '00.00.00.000'
sid = 'FPROD0'
String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
Connection conn = null;
请注意,在我们的VLAN和其他VLAN上,它运行顺畅,没问题。
我的问题是当我在我们的仓库VLAN上尝试它时根本不起作用。它无法连接到我们的Oracle数据库。
这是我的错误:
java.sql.SQLException: The Network Adapter could not establish the connection
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:133)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:199)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:480)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:413)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:508)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:203)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:33)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:510)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at digicare.tracking.serial.BulkUpload.DatabaseConnection.OracleConnection.GetDB(OracleConnection.java:59)
at digicare.tracking.serial.BulkUpload.DatabaseConnection.OracleConnection.main(OracleConnection.java:17)
at digicare.tracking.serial.BulkUpload.UploadProgress$1read2.run(UploadProgress.java:116)
at java.lang.Thread.run(Unknown Source)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the connection
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:328)
at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:421)
at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:630)
at oracle.net.ns.NSProtocol.connect(NSProtocol.java:206)
at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:966)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:292)
... 10 more
Caused by: java.net.SocketException: Malformed reply from SOCKS server
at java.net.SocksSocketImpl.readSocksReply(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:127)
at oracle.net.nt.ConnOption.connect(ConnOption.java:126)
at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:306)
... 15 more
根据我们的网络团队对仓库VLAN没有限制,我甚至可以使用仓库VLAN ping数据库服务器。这可能是什么问题?
答案 0 :(得分:0)
检查服务器的IP
和port number
。
connection = DriverManager.getConnection(
"jdbc:oracle:thin:@SERVERNAME:PORTNUMBER:SERVERID","USERNAME","PASSWWORD");