aspose file tools*
The moose likes JDBC and the fly likes JDBC Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC" Watch "JDBC" New topic
Author

JDBC

Partha Sur
Greenhorn

Joined: Feb 18, 2002
Posts: 4
Hello,
I am unable to connect to Oracle 8i 8.1.7.0 (Personal Edition) on my Windows 98 (second edition) system. I am using JDK1.3 as the jre for program development (javac, java etc). I am using the JDBC "thin" driver which was installed as classes12.zip when I installed Oracle 8i. Following are the details of my environment.
Microsoft(R) Windows 98
(C)Copyright Microsoft Corp 1981-1999.
C:\WINDOWS>set PATH=C:\jdk1.3.0_02\bin;
C:\WINDOWS>set CLASSPATH=.;D:\Oracle\Ora81\jdbc\lib\classes12.zip;
C:\WINDOWS>echo %PATH%
C:\JDK13~1.0_0\BIN;
C:\WINDOWS>echo %CLASSPATH%
.;D:\Oracle\Ora81\jdbc\lib\classes12.zip;
C:\WINDOWS>
Oracle connectivity
===================
# TNSNAMES.ORA Network Configuration File: d:\Oracle\Ora81\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
PARTHA.SUR =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = partha)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = partha.sur)
)
)
# LISTENER.ORA Network Configuration File: d:\Oracle\Ora81\network\admin\listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = partha)(PORT = 1521))
)
)
(DESCRIPTION =
(PROTOCOL_STACK =
(PRESENTATION = GIOP)
(SESSION = RAW)
)
(ADDRESS = (PROTOCOL = TCP)(HOST = partha)(PORT = 2481))
)
)
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = d:\Oracle\Ora81)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = partha.sur)
(ORACLE_HOME = d:\Oracle\Ora81)
(SID_NAME = partha)
)
)
And now the program
===================
import java.sql.* ;
class TestThinApp
{
public static void main (String args [])
throws ClassNotFoundException, SQLException
{
Class.forName ("oracle.jdbc.driver.OracleDriver") ;
Connection conn = DriverManager.getConnection (
"jdbc racle:thin:@partha:1521 artha", "scott", "tiger") ;
Statement stmt = conn.createStatement () ;
ResultSet rset = stmt.executeQuery (
"select 'Hello Thin Driver Tester '||USER||'!' result from dual") ;
while (rset.next ())
System.out.println (rset.getString (1)) ;
rset.close () ;
stmt.close () ;
conn.close () ;
}
}
When I run this I get exception
===============================

C:\myJava\jdbc>javac TestThinApp.java
C:\myJava\jdbc>java TestThinApp
Exception in thread "main" java.sql.SQLException: Io exception: The Network Adap
ter could not establish the connection
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java)
at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java)
at oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.ja
va)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java)
at java.sql.DriverManager.getConnection(DriverManager.java:517)
at java.sql.DriverManager.getConnection(DriverManager.java:177)
at TestThinApp.main(TestThinApp.java:10)
C:\myJava\jdbc>
PLEASE HELP !!!
I seem to have followed all the rules ...
I have been trying for a long time and would like help with resolution.
I also tried downloading the JDBC "thin" driver
for Oracle 8.1.7.0 but the Oracle site only lists the 8.1.7 thin drivers for NT. Does this work for Windows 98 also ? So I am using the drivers that came with the Oracle 8i 8.1.7 (Personal) installation CD.
Does the JDBC "thin" driver not work with the Personal edition Oracle 8i database ?
Thanks in advance for any help.
Regards,
Partha Sur
Rajendar Goud
Ranch Hand

Joined: Mar 06, 2002
Posts: 220
Hi ,
i think while using Thin drivers,u need to register the driver first..here is a sample of code which uses thin drivers..
DriverManager.registerDriver (new oracle.jdbc.driver.OracleDriver());
Connection conn = DriverManager.getConnection
("jdbc racle:thin:@qit-uq-cbiw:1526 rcl", "scott", "tiger");
// @machineName ort:SID, userid, password
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select BANNER from SYS.V_$VERSION");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();

Hope it works for u....
Raj
Prashanth menon
Ranch Hand

Joined: Feb 20, 2001
Posts: 65
It is not the problem with the thin driver.
It is because the SID or the host in the url string is invalid.
In the TNSNAMES.ORA I think you have configured service name as partha.sur
The code hence should be

I hope it works out for you.
regards
Prashanth
Partha Sur
Greenhorn

Joined: Feb 18, 2002
Posts: 4
Hi all,
I fixed the problem ... The Oracle listener was not running. This gave the adapter error.
So I checked the listener status by
lsnrctl status
and then started the listener:
lsnrctl start
After that I was able to connect with no change in code ... The URL was correctly coded.
Anyway thanks to all for your help.
Best wishes,
Partha
 
Don't get me started about those stupid light bulbs.
 
subject: JDBC