Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2006

Tip: Looking for answers? Try searching our database.

Urgent: connection not made using JDBC Thin Drivers

Thread view: 
Ramji - 04 May 2006 06:37 GMT
Dear friends:
following code just prints
Connecting to Oracle... &  it doesnt prints ....Connected to oracle
statement.
I've given the code in try catch block but also it doesn't print any
exception
why??

System.out.println("connencting to Oracle....");

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

Connection conn=
DriverManager.getConnection("jdbc:oracle:thin:@(DESCRIPTION
=(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = testserver.com)(PORT
= 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME =
testdb)))","test","test");

System.out.println(".....connencted to Oracle");

I've tried the above code with some changes for the database on the
same machine it works fine. But when I tries it for the db on the other
server it not works.

waiting for reply.....
stixwix - 04 May 2006 09:27 GMT
> Dear friends:
> following code just prints
[quoted text clipped - 21 lines]
>
> waiting for reply.....

Could it be simply that the code is throwing an exception?  Wrap it in
a try-catch block...
stixwix - 04 May 2006 09:50 GMT
> Could it be simply that the code is throwing an exception?  Wrap it in
> a try-catch block...

Sorry - i didn't read the question properly!
Bjorn Abelli - 04 May 2006 10:12 GMT
"Ramji" wrote...

> following code just prints
> Connecting to Oracle... &  it doesnt prints ....Connected to oracle
> statement.
> I've given the code in try catch block but also it doesn't
> print any exception
> why??

What do you do with the exception you catch?

When caught, the exception doesn't "print itself".

If it happens that you catch an exception, but don't do anything with it
(e.g. print out the stacktrace), you'll not see anything.

Could that be the case here?

> System.out.println("connencting to Oracle....");
>
[quoted text clipped - 5 lines]
> = 1521)))(CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME =
> testdb)))","test","test");

This seems a bit overkill to supply the whole Net8 configuration file when
working with the thin driver... ;-)

It should suffice with:

 DriverManager.getConnection(
   "jdbc:oracle:thin:@testserver.com:1521:testdb",
   "test", "test");

// Bjorn A


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.