0

I have a dynamic jtree in netbeans using Oracle XE.

I have made a connection() method in packageA and use the connection() method in pacakge B.

Earlier it was not giving the error but now the connection method work perfectly fine some times & and some times it show the error message error java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12516)(ERROR_STACK=(ERROR=(CODE=12516)(EMFI=4)))).

My code is following for getConnection()

public class IntegrationWithDbClass {

public Connection conn = null;
public Statement stmt = null;
public ResultSet rs = null;
public String query = "";

        public void getConnection() {

    try {
        Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
 String url="jdbc:oracle:thin:@localhost:1521:XE";
 conn = DriverManager.getConnection(url, "Hr", "Hr");
System.out.println("Connection Established");
        if (this.conn != null) {
            this.conn.setAutoCommit(false);
            this.stmt = this.conn.createStatement();
        }
    } catch (Exception ex) {
        System.out.println("error "+ex);
        ex.printStackTrace();
    }

}
  }

I know that some people said its because of SID, but I don't think my error occurs because of SID, there is some other problem, need your help thanks.

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
shaun Tait
  • 33
  • 6
  • Please post the full exception stacktrace, and explain why you think your problem is not related to the SID. Note that a connection refused means that on a low level the socket connection could not be established, which would mean that either Oracle is not running on the specified port, or a firewall is blocking your connection. – Mark Rotteveel May 15 '18 at 12:03
  • 'Connection refused' means exactly one thing. Nothing was listening at the IP:port you tried to connect to. It has nothing to do with 'flaky network connections', firewalls, etc. @MarkRotteveel – user207421 May 15 '18 at 12:04
  • @EJP You're right, fixed it. But firewalls can be involved if they are configured to reject instead of drop, and other reason - on Windows - could be that the accept queue is full. – Mark Rotteveel May 15 '18 at 12:06

0 Answers0