Skip to Main Content

Java Development Tools

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

[b]Connection to Oracle DB per JDBC URGENT HELP NEEDED PLEASE![/b]

428490Jan 7 2005 — edited Jan 8 2005
Hallo,
I'm a newbie. I want to make a connection to the oracle db on the server and I have been having serious problems. See CODE and ERROR MESSAGEs below:


import java.sql.*;
public class SqlConnection01 {
public static void main(String[] args) {
Connection con = null;
Statement stmt = null;
try {
Class.forName("oracle.jdbc.driver.OracleDriver"); //Loading the Oracle Driver.
con = DriverManager.getConnection
("jdbc:oracle:thin:@38.218.2.227:1521:testdb","data","test"); //making the connection.
stmt = con.createStatement ();// Sending a query to the database
ResultSet rs = stmt.executeQuery("SELECT mand,kost,ktest,kok FROM test");
while (rs.next()) {
String mandt = rs.getString("1");
String kostl = rs.getString("2");
String ktest = rs.getString("3");
String kokrs = rs.getString("4");
System.out.println( mandt + kostl ktest kokrs );
}
} catch(Exception e) {
e.printStackTrace();
} finally {
try
{
if(stmt != null) stmt.close();
if(con != null) con.close();
} catch (Exception exception) {
exception.printStackTrace();
}
}
}
}


ERROR MESSAGE:

java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=153092352)(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:334)
at oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3695)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:352)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:362)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:536)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:328)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at SqlConnection01.main(SqlConnection01.java:24)


What am I doing wrong here. I am using Oracle9i client installed on my pc (Release 2 (9.2.0.1.0) for Windows ) so I downloaded the ojdbc14 drivers for this version and I copied them in my bin directory C:\j2sdk1.4.2_06\bin\ojdbc14 .
Secondly I can connect to the db per command line( sqlplus /nolog; conn data/test@testdb) and querry the testdb.
I can also test the connection using oracle Net Manager and the test is successful.

But I can't start up the lsnrctl on my pc.I get this message any time i issue the command(C:\>lsnrctl
'lsnrctl' is not recognized as an internal or external command, operable program or batch file.)

What am I doing wrong here? What should I do to have this connection possible. Thanks very much in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 5 2005
Added on Jan 7 2005
16 comments
458 views