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)
)
)
-Nathan
"cel" <papou...@yahoo.com> wrote in message news:<3d08e10a$0$597$626a...@news.free.fr>...
Where shall i check these parameters ?
"Nathan Zumwalt" <nat...@hotmail.com> wrote in message
news:521673fd.02061...@posting.google.com...
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...
"bhogak" <bho...@attbi.com> wrote in message
news:DGzO8.191196$352.11714@sccrnsc02...
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...
[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...
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...
"Cel" <cefe...@capgemini.fr> wrote in message
news:3d0db94f$0$464$626a...@news.free.fr...
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...