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.