Im having a little bit of difficulty solving this simple error... I
konw I have the URL correct, however I cannot connect to the Oracle 9
database.
The error occurs on the line that I assign the connection (ConDB), Im a
little lost, any help is appreciated!
Thanks!
----
strURL = "jdbc:oracle:thin:@oradev.xxx.com:1521:dev.xxx.com";
strUser = "user"
strPass = "pass"
try {
//register oracle driver
DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());
// DB logon
ConDB = DriverManager.getConnection (strURL , strUser, strPass);
}
-------
java.sql.SQLException: Io exception: Connection
refused(DESCRIPTION=(TMP=)(VSNNUM=153093632)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:334)
at
oracle.jdbc.ttc7.TTC7Protocol.handleIOException(TTC7Protocol.java:3678)
at oracle.jdbc.ttc7.TTC7Protocol.logon(TTC7Protocol.java:352)
at
oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:365)
at
oracle.jdbc.driver.OracleDriver.getConnectionInstance(OracleDriver.java:547)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:347)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at PhoneLookup.main(PhoneLookup.java:38)
java.lang.NullPointerException
at PhoneLookup.main(PhoneLookup.java:46)
java.lang.NullPointerException
at PhoneLookup.main(PhoneLookup.java:67)
Joe Weinstein - 05 Apr 2005 20:54 GMT
> Im having a little bit of difficulty solving this simple error... I
> konw I have the URL correct, however I cannot connect to the Oracle 9
[quoted text clipped - 9 lines]
> strUser = "user"
> strPass = "pass"
Either your user and password are incorrect, or the last part of your
URL is wrong. Ie: "dev.xxx.com" may be the machine to connect to,
but the last part of the URL is the SID of the DBMS. You need to verify
what the SID of the DBMS is...
Joe Weinstein at BEA
> try {
> //register oracle driver
[quoted text clipped - 26 lines]
> java.lang.NullPointerException
> at PhoneLookup.main(PhoneLookup.java:67)
6e - 05 Apr 2005 21:12 GMT
Well... i checked that information, but I *think* it's all currently
correct... I included the tnsnames section for reference, please tell
me if Im missing something silly... thanks
DEV =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = oradev.xxx.com)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dev.xxx.com)
)
)
Joe Weinstein - 05 Apr 2005 21:29 GMT
> Well... i checked that information, but I *think* it's all currently
> correct... I included the tnsnames section for reference, please tell
[quoted text clipped - 9 lines]
> )
> )
That does seem to show the right SID, machine, and port. Have you checked
that you can connect with SQL-plus with that tnsnames.ora file, and the
user and password you're using?
Joe
6e - 05 Apr 2005 21:41 GMT
Is it possible that it could be a driver issue?
I can connect via sql plus...
(thank you for your help!)
Joe Weinstein - 05 Apr 2005 22:21 GMT
> Is it possible that it could be a driver issue?
>
> I can connect via sql plus...
>
> (thank you for your help!)
No. The driver connected to the DBMS. The DBMS refused to provide a connection.
Something is wrong with your user/password or more likely the SID.
See if you can connect with SQL-PLUS and do a query that returns you what the DBMS thinks
it's SID is.
Joe
Andy Flowers - 05 Apr 2005 23:17 GMT
> Well... i checked that information, but I *think* it's all currently
> correct... I included the tnsnames section for reference, please tell
[quoted text clipped - 9 lines]
> )
> )
This could be wrong, but if I recall...
The thin driver requires the SID.
The entry (SERVICE_NAME = dev.xxx.com) in Oracle 8i speak is the 'service
name' which is a nice friendly name that can be used. The SID is an 'older'
way of working and refers to what the actual database server has as it's
name there.
You need to ask your DBA what the SID is or take alook at the server and
find out. It might be different, and if I recall it will be as they're
limited to 8 characters.
Mark Bole - 07 Apr 2005 02:26 GMT
> Im having a little bit of difficulty solving this simple error... I
> konw I have the URL correct, however I cannot connect to the Oracle 9
[quoted text clipped - 14 lines]
> )
> )
Try the following syntax for your URL, which eliminates the possibility
of a faulty tnsnames.ora entry:
-----[wrapped for display purposes - one line]-----------
jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)
(HOST=xxx)(PORT=1521))
(CONNECT_DATA=(SERVICE_NAME=yourdb.yourdomain)))
------------[end]--------------------------------
Somewhere along the way, I picked up the empirical notion that the thin
driver did not consult the tnsnames.ora (Oracle Net) config file at all.
Is this true?
-Mark Bole
HansF - 07 Apr 2005 05:19 GMT
> Somewhere along the way, I picked up the empirical notion that the thin
> driver did not consult the tnsnames.ora (Oracle Net) config file at all.
> Is this true?
Totally true. The thin driver was originally intended to be downloaded to
the client dynamically on demand - no preconfiguration or setup, and no
TNSNAMES.ora.
(The OCI driver basically punts from Java to OCI to traditional SQLNet and
uses TNSNAMES.ora. For Oracle9i the OCI driver is required for performance
and for full database SQL functionality as thin only has a subset of OCI
driver capabilities.
The OP's issue really depends on using the SID that the listener
recognizes. Usually that means dropping the ".abc.com" from the global
database name.

Signature
Hans Forbrich
Canada-wide Oracle training and consulting
mailto: Fuzzy.GreyBeard_at_gmail.com
*** I no longer assist with top-posted newsgroup queries ***
kaeli - 05 Apr 2005 21:55 GMT
> Im having a little bit of difficulty solving this simple error... I
> konw I have the URL correct, however I cannot connect to the Oracle 9
> database.
>
> The error occurs on the line that I assign the connection (ConDB), Im a
> little lost, any help is appreciated!
It's the database listener, quite likely. Check out the config file for
oracle (or have your DBA do it).
Either that or you've got a typo somewhere in the user name, database name,
or password.
> java.sql.SQLException: Io exception: Connection
> refused(DESCRIPTION=(TMP=)(VSNNUM=153093632)(ERR=12505)
See oracle docs for error 12505.
ORA-12505: TNS: listener could not resolve SID given in connection
description.

Signature
--
~kaeli~
Humpty Dumpty was pushed!
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace
HansF - 05 Apr 2005 23:15 GMT
> Im having a little bit of difficulty solving this simple error... I
> konw I have the URL correct, however I cannot connect to the Oracle 9
> database.
> <snip>
As Joe says, it looks like a connect string problem. One fairly common
issue - you are using the "service name" as the final parameter, and that
is occasionally different from the SID. For the sake of amusement (mine),
try changing the "dev.xxx.com" to "dev"
Perhaps you can get additional hints in the Oracle docco at
http://download-west.oracle.com/docs/cd/B10501_01/java.920/a96654/getsta.htm#1008461
<unsolicited advice>
Since you are heading down this path, I make you aware that Oracle has a
LOT of related documentation, available free of charge from
http://docs.oracle.com ... pick 'version' > 'view library' > 'books'. In
particular consider the following, in order:
Concepts
- handy 'how does it work' and 'why doesn't it do it this way' guide
Application Developer's Guide - Fundamentals
- specifically how to avoid problems encountered in 'generic' coding.
JDBC Developer's Guide and Reference
- a good skim showing the minor differences to generic JDBC
Java Developer's Guide
- good extensions and tricks
Supplied Java Packages Reference
- the freebies you don't have to duplicate
Supplied PL/SQL Packages Reference
- more of the same, but written in PL/SQL
interMedia Java Classes User's Guide and Reference
- more of the same for text, graphics and geocode
XML API Reference - XDK and Oracle XML DB
</unsolicited advice>
/Hans