Here is my java connectivity code to Oracle
public class OracleConnectivity {
public Connection con;
public Connection getConnection ()
{
try
{
Class.forName("oracle.jdbc.driver.OracleDriver");
con=DriverManager.getConnection("jdbc:oracle:thin:@127.0.0.1:1521:dhanesh","dhanesh","root");
Statement s=con.createStatement();
s.executeUpdate("insert into test (num,txt) values (2,'hi')");
s.close();
con.close();
}
catch(Exception e)
{
System.out.println("Connection failed");
e.printStackTrace();
}
return con;
}
public static void main(String[] args) {
OracleConnectivity O=new OracleConnectivity();
O.getConnection();
}
}
The error i am getting is
java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=169869568)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:333)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:404)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:468)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:314)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at dhanesh.OracleConnectivity.getConnection(OracleConnectivity.java:24)
at dhanesh.OracleConnectivity.main(OracleConnectivity.java:40)
i've ojdbc14 jar file in jdk1.6.0->jre->lib->ext folder
please help me out to resolve this error