Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

jdbc:oracle:thin:@

5 views
Skip to first unread message

cel

unread,
Jun 13, 2002, 2:17:57 PM6/13/02
to
When trying to run the program below to test the connexion with my database
(Oracle 9i with W2K),
i get this error message:

I don't know where the problem is.
Database is started, and listener too.
Help needed !

E:\>java -cp .;E:\oracle\ora90\jdbc\lib\classes111.zip dbAccess
Exception in thread "main" java.sql.SQLException: Exception d'E/S: The
Network A
dapter 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.java)
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 dbAccess.main(dbAccess.java:9)


Here is the program
---------------------------------
import java.sql.*;
class dbAccess {
public static void main (String args []) throws SQLException
{


DriverManager.registerDriver (new
oracle.jdbc.driver.OracleDriver());

Connection conn = DriverManager.getConnection
("jdbc:oracle:thin:@bobbyt:1521:basestar", "scott", "tiger");
// @machineName:port:SID, userid, password

Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select ename from scott.emp");
while (rset.next())
System.out.println (rset.getString(1)); // Print col 1
stmt.close();

}
}


And my TNSNAMES.ORA file :
-------------------------------------------------------
# TNSNAMES.ORA Network Configuration File:
E:\oracle\ora90\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)

)

)

BASESTAR =

(DESCRIPTION =

(ADDRESS_LIST =

(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))

)

(CONNECT_DATA =

(SID = BASESTAR)

(PRESENTATION = RO)

)

)

Sergi Calvet Rodríguez

unread,
Jun 13, 2002, 7:06:34 PM6/13/02
to
Try classe12.zip
"cel" <papou...@yahoo.com> escribió en el mensaje
news:3d08e10a$0$597$626a...@news.free.fr...

Nathan Zumwalt

unread,
Jun 13, 2002, 8:53:30 PM6/13/02
to
It looks like for whatever reason, the driver can't connect to the
database server. Can you ping the server? Have you tried specifying
the IP address instead of the hostname? Are you sure the port number
is correct?

-Nathan

"cel" <papou...@yahoo.com> wrote in message news:<3d08e10a$0$597$626a...@news.free.fr>...

cel

unread,
Jun 14, 2002, 1:56:11 AM6/14/02
to
I tried, it doesn't work either. same error message.
"Sergi Calvet Rodríguez" <9344...@terra.es> wrote in message
news:_z9O8.9041$PT3.1...@telenews.teleline.es...

cel

unread,
Jun 14, 2002, 1:58:27 AM6/14/02
to
I tried with the IP of my comp, and it doesn't work either.
I don't remember where I got the 1521 port.

Where shall i check these parameters ?


"Nathan Zumwalt" <nat...@hotmail.com> wrote in message
news:521673fd.02061...@posting.google.com...

bhogak

unread,
Jun 15, 2002, 12:48:39 AM6/15/02
to
Port 1521 is the default port oracle listens on. So you do not need to
change it. Is Oracle running on a different machine? If so, give its IP
address instead of bobby in your Connection String.

Try to do either a "tnsping basestar" or connect through Sql*Plus to make
sure that you are actually able to w2k server.

--
bhogak


"cel" <papou...@yahoo.com> wrote in message

news:3d098530$0$278$626a...@news.free.fr...

cel

unread,
Jun 15, 2002, 3:00:07 PM6/15/02
to
Oracle is running on the same machine.
And tnsping basestart works fine, and SQL*Plus too.

"bhogak" <bho...@attbi.com> wrote in message
news:DGzO8.191196$352.11714@sccrnsc02...

bhogak

unread,
Jun 15, 2002, 8:20:19 PM6/15/02
to
I did not use 9i, I am writing this based on my experiences with 8i.

1. When connecting from SQL*Plus, I assume you are explicitly mentioning the
database sid..ie., you are mentioning scott/tiger@basestar instead of just
scott/tiger (this will work because your database is on the same machine).
2. Your Database is not configured for MTS. If you are using MTS, there is a
bug with the JDBC driver. They are many articles on this on Metalink.
3. Have you tried using OCI driver or classes12.zip driver?

If nothing works, I suggest posting in comp.databases.oracle.server.


--
bhogak
"cel" <papou...@yahoo.com> wrote in message

news:3d0b8e10$0$235$626a...@news.free.fr...

AV

unread,
Jun 16, 2002, 1:45:58 PM6/16/02
to
Thin driver uses tcp/ip directly to (if default) 1521 port
in Oracle server pc.
TNSNAMES, tnsping, sqlplus are nothing to do
with "thin" driver.

[let say IP is ip of Oracle machine]
As was suggested before, try (sorry, may be once more time) if:
-- Oracle pc is accessible : ping IP
-- Oracle listener is up : telnet IP 1521
-- Oracle instance of your interest is running :
try to connect to this database by any means -
sqlplus, oem, bentik, toad
-- there is right SID in java connection url
-- Oracle listener is configured properly:
start lsnrctrl.sh (.bat) and enter "status" there

Good luck...

AlexV.


"cel" <papou...@yahoo.com> wrote in message

news:3d0b8e10$0$235$626a...@news.free.fr...

Cel

unread,
Jun 17, 2002, 6:21:31 AM6/17/02
to
I tried all this and i don't have any problem to connect to my database
using Toad, SQL*Plus etc ...

I noticed that my TNSNAMES.ora doesn't have any line with
HOST = name_of_host .
Could it be the problem ?

I've been surfing like crazy for hours to find an answer to this problem
and i'm really starting to think Oracle and Sun should work more closely
because setting up a JDBC driver is very annoying !!!!

Please help !

"AV" <avek_...@videotron.ca> a écrit dans le message news:
v84P8.2077$IY2.1...@wagner.videotron.net...

Oleg

unread,
Jun 17, 2002, 8:30:21 AM6/17/02
to
I have same problem! Try
lsnrctl stop
lsnrctl start


"Cel" <cefe...@capgemini.fr> wrote in message
news:3d0db94f$0$464$626a...@news.free.fr...

Elton Saulsberry

unread,
Jun 27, 2002, 2:01:12 PM6/27/02
to
I'm pretty new at this so if I'm displaying my ignorance excuse me.
I've been going through the JDBC tutorial and they say to insert

Class.forName("oracle.jdbc.driver.OracleDriver");

above your DriverManager line. Here is my working code...

public class Main {
private Statement stmt;
private Connection con;

/** Creates a new instance of Main */
public Main() {
}

private void doConnection() throws ClassNotFoundException, SQLException {
Class.forName("oracle.jdbc.driver.OracleDriver");
con = DriverManager.getConnection("jdbc:oracle:thin:@baltimore:1521:demo",
"ejava", "ejava");
con.setAutoCommit(false);
stmt = con.createStatement();
}

"cel" <papou...@yahoo.com> wrote in message

news:3d08e10a$0$597$626a...@news.free.fr...

0 new messages