Two Laptop Bag*
The moose likes JDBC and the fly likes Oracle JDBC unable to get connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Oracle JDBC unable to get connection" Watch "Oracle JDBC unable to get connection" New topic
Author

Oracle JDBC unable to get connection

Paulus Liem
Greenhorn

Joined: Dec 21, 2001
Posts: 5
I just started learning JDBC and I have Oracle 8.1.7 and JDK1.3.1 installed on my computer.
This is my autoexec.bat:
set path=c:\jdk1.3.1\bin;c:\oracle\ora81\bin;c:\oracle\ora81\jdbc\lib;
set classpath=c:\oracle\ora81\jdbc\lib\classes12.zip;c:\oracle\ora81\jdbc\lib\nls_charset12.zip
1. is this the correct setting ?
the documentation said that classes12.zip is dedicated for jdk1.2
is there a specific oracle.jdbc.driver for jdk1.3?
When I was installing oracle 8.1.7 ( downloaded from oracle site)
I was asked to enter the database name, and I entered "Oracle"
and the suggested SID is also "Oracle"
so the database (host:port:sid) for connection is:
@localhost:1521:Oracle
or @127.0.0.1:1521:Oracle
is this correct, since I keep getting error messages?
Please somebody help me.
Thanks
(Edited by Dave to fix the smilie problems)
[ January 03, 2002: Message edited by: David O'Meara ]
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
What error messages are you getting? What operating system are you on?
Paulus Liem
Greenhorn

Joined: Dec 21, 2001
Posts: 5
Stanley
I currently use Windows 98 second Ed.
Here is the error message:
Error Messages:
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:323)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:263)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:365)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:260)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at JDBCVersion.main(JDBCVersion.java:10)
But it works fine if I use OCI8 instead of thin driver ( "jdbc:oracle:oci8:@","scott","tiger")
Thanks
( Edited by Dave to fix the :o )
[ January 03, 2002: Message edited by: David O'Meara ]
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
You must have listeners set up which I don't know how to do on Windows 98.
Just a wild guest: have you tried "ORCL" instead of "Oracle" for the SID.
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
BTW, what's your connection string?
It should be something like:
conn = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl", "username", "password");
[ January 04, 2002: Message edited by: Stanley Tan ]
(Edited by Dave to remove try &#58;o instead)
[ February 21, 2002: Message edited by: David O'Meara ]
Paulus Liem
Greenhorn

Joined: Dec 21, 2001
Posts: 5
I have tried all combination of connection string:
("jdbc:oracle:thin:@localhost:1521:oracle",user,pwd);
("jdbc:oracle:thin:@localhost:1521:orcl",user,pwd);
("jdbc:oracle:thin:@mycom:1521:orcl",user,pwd);
("jdbc:oracle:thin:@mycom:1521:oracle",user,pwd);
// where "mycom" is my computer name
(Edited by Dave to remove try &#58;o instead)
[ February 21, 2002: Message edited by: David O'Meara ]
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
I am on Windows XP so I am able to start and stop listeners. Check your Oracle documentation on how to do this for Windows 98. You want to start a TNS listener.
Sorry I am not of much help.
Or perhaps you could just use the JDBC ODBC driver for now.
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

if you do a search on the jdbc forum using the parameters 'localhost connection oracle' you get five results that might be helpful to you
Jamie
Paulus Liem
Greenhorn

Joined: Dec 21, 2001
Posts: 5
Thanks alot guys.
By the way, I also have Windows XP installed on my machine. If someday I want to install Oracle on it, which Oracle version should I use?
Is it the one for Windows NT ?
Thanks again
Stanley Tan
Ranch Hand

Joined: May 17, 2001
Posts: 243
Yup, the one for NT as XP is actually NT 5.1.
Good luck!
Gregory Garrison
Ranch Hand

Joined: Oct 05, 2001
Posts: 107
Just figured this one out. Had the exact problem - could connect using the oci driver but not the thin client. Real problem is that the listener has not been started. Solution (on linux) is to go into the "lsnrctl" commandline utility and enter "start". Does anyone know how to automatically start the listener services on a unix box when the server starts? Much appreciated.
Paulus Liem
Greenhorn

Joined: Dec 21, 2001
Posts: 5
Hi,
I managed to solve this problem just by re-installing Oracle and everything is just fine.
Paulus Liem
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Oracle JDBC unable to get connection
 
Similar Threads
JDBC
WebLogic6.1/Oracle8.1.6 config problem (obvious to someone?)
Running Tomcat as service; JDBC not working now
JDBC driver - java lang ClassNotFoundException
Unsatisfied Link Error