0

我在使用 Netbeans 或 SQuirrel 等客户端连接到 Oracle 数据库时遇到问题。我的操作系统是 Windows 7。

我位于已为此测试用例停用的防火墙后面。

如果我尝试使用普通 java 连接到数据库,例如:

public static void main(String[] args) {
    Connection connection = null;
    try {
        // Load the JDBC driver
        String driverName = "oracle.jdbc.driver.OracleDriver";
        Class.forName(driverName);

        // Create a connection to the database
        String serverName = "servername";
        String portNumber = "1521";
        String sid = "sid";
        String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + "/" + sid;
        String username = "user";
        String password = "pass";
        connection = DriverManager.getConnection(url, username, password);
        System.out.println(url);
    } catch (ClassNotFoundException | SQLException e) {
        e.printStackTrace();
    } finally {
        try {
            System.out.println("connection read only:" + connection.isReadOnly());
            System.out.println("connection closed:" + connection.isClosed());
            System.out.println("connection isValid:" + connection.isValid(500));
            connection.close();
            System.out.println("connection closed:" + connection.isClosed());                
        } catch (SQLException ex) {
            Logger.getLogger(JavaApplication3.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

输出是:

URL
connection read only:false
connection closed:false
connection isValid:true
connection closed:true

所以,这很好用。

但是,如果我尝试通过 Netbeans、Squirrel 等任何工具进行连接,我总是会遇到类似的错误

at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Caused by: oracle.net.ns.NetException: The Network Adapter could not establish the Connection   
// ... 
Caused by: java.net.SocketException: Malformed reply from SOCKS erver

我不知道下一步该做什么.. 有什么好的提示我可以尝试下一步吗?

4

0 回答 0