Skip to Main Content

Java Database Connectivity (JDBC)

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!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

Problem with connect to oracle by jdbc

2717954Mar 19 2009 — edited Mar 20 2009
hi,

First time i try to connect to the oracle db 10.2.0* EE in java and its problem. I use eclipse 3.4, jre1.5.0_17, driver ojdbc14.jar (dedicated to this oracle ver and jre).


package connect;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JDBC_Conn {
void polaczenie_z_baza() throws SQLException {
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("connected");
} catch (Exception e) {
System.out.println("not connected");
}

Connection polaczenie=DriverManager.getConnection("jdbc:oracle:thin:@3.123.123.321:1521:RI3","user","pass");
}

public static void main(String[] args){
JDBC_Conn b = new JDBC_Conn();
try {
b.polaczenie_z_baza();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}



and after run in console i see: "connected" but after 2 seconds i see error:



java.sql.SQLException: Wyjątek we-wy: The Network Adapter could not establish the connection
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at connect.JDBC_Conn.polaczenie_z_baza(JDBC_Conn.java:18)
at connect.JDBC_Conn.main(JDBC_Conn.java:24)



This is important that i can login to the database by pl/sql developer using tnsnames.ora like this:


CIF2 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 3.123.123.321)(PORT = 1521))
)
(CONNECT_DATA =
(SID = RI3)
)
)


but when im logging by plsql developer i need to enter the name of database "DWH" too, another i cant login. The same when i log by sql plus, i need to enter the: user@DWH.

So please tell me could i add to this string:
"jdbc:oracle:thin:@3.123.123.321:1521:RI3","user","pass"
the DWH database? where i should to put it?

i try a lot of cases and cant login

thanks for help
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 17 2009
Added on Mar 19 2009
5 comments
3,203 views