Question

Accessing oracle from remote machine

Asked by: wilma22

I am running a JSP application on Tomcat Server with oracle 8i as database.
Oracle server is maintained on a seperate machine and all the developers access the same Oracle server for developing while they have tomcat installed seperately on their respective machines.

If i install tomcat on the machine in which oracle is installed and try to access oracle using the following code in my JSP, it works perfectly fine.

 Class.forName("oracle.jdbc.driver.OracleDriver");
      return DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1521:orcl", "scott", "tiger");

 But if the same code(changing the ip to oracle server's id, so the code would be    
   return DriverManager.getConnection ("jdbc:oracle:thin:@192.168.27.32:1521:orcl", "scott", "tiger");
), is used by a developer in his JSP using his local tomcat server and trying to access the orace server, she gets the following error.

java.sql.SQLException:Io Exception: The Network adapter could not establish a connection.

What we want to acheive is that although every developer has a web server seperately on her machine, the oracle server should be installed on only one machine and each developer should access that for developing her JSP application.
Thanks

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-04-30 at 05:14:06ID20973477
Tags

code

,

developer

,

oracle

Topic

Oracle Product Info

Participating Experts
2
Points
0
Comments
13

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Oracle, JDBC, JSP
    My config: Win2000, Oracle, JSP (with tomcat), jdk1.2.2, jsdk2.0 I need a piece of code for connecting an oracle database using JDBC.

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: schwertnerPosted on 2004-04-30 at 05:25:56ID: 10958833

You are attempting to connect to an Oracle instance using JDBC
and you are receiving the following error.
 
   java.sql.SQLException: Io exception:  
     The Network Adapter could not establish connection
 
   SQLException: SQLState (null) vendor code (17002)
 
Any or all of the following conditions may also apply:
 
1) You are able to establish a SQL*Plus connection from the same
   client to the same Oracle instance.
 
2) You are able to establish a JDBC OCI connection, but not a Thin
   connection from the same client to the same Oracle instance.
 
3) The same JDBC application is able to connect from a different
   client to the same Oracle instance.
 
4) The same behavior applies whether the initial JDBC connection
   string specifies a hostname or an IP address.
 
REDISCOVERY
-----------
 
To verify whether you are hitting this problem, verify whether the
Oracle instance is configured for Multithreaded Server (MTS).
 
If the Oracle instance is not configured for MTS, you are probably
encountering a different problem. Otherwise, continue.
 
Try forcing the JDBC connection to use a dedicated server instead
of a shared server. This can be accomplished in several ways.
 
For JDBC OCI or Thin, this can be done by reconfiguring the server
for dedicated connections only. This approach, however, may not be
feasible in many cases. In such cases, the following options apply:
 
For JDBC OCI:
 
1) Add the (SERVER=DEDICATED) property to the TNS connect string
   stored in the tnsnames.ora file on the client.
 
2) Set the user_dedicated_server=ON in sqlnet.ora on the client.
 
For JDBC Thin:
 
You must specify a full name-value pair connect string (the same
as it might appear in the tnsnames.ora file) instead of the short
JDBC Thin syntax. For example, instead of
 
   "jdbc:oracle:thin:@host:port:sid"
 
you would need to use a string of the form
 
   "jdbc:oracle:thin:@(DESCRIPTION="                   +
                         "(ADDRESS_LIST="              +
                             "(ADDRESS=(PROTOCOL=TCP)" +
                                      "(HOST=host)"    +
                                      "(PORT=port)"    +
                             ")"                       +
                         ")"                           +
                         "(CONNECT_DATA="              +
                             "(SERVICE_NAME=sid)"      +
                             "(SERVER=DEDICATED)"      +
                         ")"                           +
                       ")"
 
If the connection works fine after having made these changes, it
is very likely that this is the problem you are encountering. In
this case, one last test will help to verify this fact.
 
Log into the remote host on which the Oracle instance is running
and execute the appropriate command to determine what the server
'thinks' its hostname is (i.e. the name that was configured when
the server was installed and configured). For example, on a Unix
host the 'hostname' command can be used for this purpose.
 
Using the name displayed (e.g. by the hostname command), exactly
as it appeared (i.e. if the output from the hostname command had
the domain name included, then include it), return to the client
which was unable to connect and try pinging the server.
 
NOTE: It is critical that you attempt to ping the server using
      EXACTLY the same hostname you got from the server.
 
If you are unable to ping the server via this hostname, then you
almost certainly hitting this problem. If not, this may be a new
issue, but at least you will have found a workaround (i.e. use a
dedicated connection).
 
EXPLANATION
-----------
 
To understand why this problem occurs, one must first understand
the differences in how the listener handles connections to shared
servers versus dedicated servers.
 
When connecting to a dedicated server, the client connects to the
listener (via hostname or IP address). The listener then spawns a
dedicated server process and hands off the socket used to accept
the client connection to that server. The client and server then
start communicating via the endpoints established by the initial
connection. NOTE: There is only one connection in this case.
 
When connecting to a shared server, the initial client connection
to the listener is the same. However, with MTS, there is no need
to spawn a new server process; a pool of shared processes already
exists. Also, clients do not communicate directly with the server
processes in MTS; rather, they communicate with a dispatcher.
 
For this reason, when setting up an MTS connection, the listener
sends a redirect message back to the client asking the client to
close the connection to the listener and connect to a dispatcher.
The information in this message includes the hostname and a port
number for the appropriate dispatcher. The redirect message will
ALWAYS specify a hostname, even if the client initially provided
an IP address.
 
If, for any reason, the hostname provided to the listener (e.g. by
the 'hostname' or another command) doesn't agree with the hostname  
by which the server is known on the client, the connection fails.
 
On the other hand, if "(SERVER=DEDICATED)" already appears in the
TNS connect string in tnsnames.ora or if "use_dedicated_server=ON"
already appears in the sqlnet.ora file, you may find that SQL*Plus
and/or JDBC OCI work fine, while JDBC Thin fails.
 
SOLUTION
--------
 
Obviously, one solution is to use dedicated servers. However, this
may not always be feasible.
 
The key is to make sure the hostname on both the client and server
agree. This can be accomplished by reconfiguring either the client
or the server, but there are things to be aware of in both cases.
 
If the server is configured to return a different hostname, then it
is possible that other clients which used to work will now fail.
 
In some cases, it may not be feasible to reconfigure the client. For
example, if the server version of the hostname does not include the
domain, you would need to remove the domain portion of the hostname
on the client; but, if the client needs to connect to more than one
server with the same base name in different domains, this may not be
possible, as the hostname may be ambiguous.

 

by: wilma22Posted on 2004-05-02 at 23:32:56ID: 10975066

I tried using

"jdbc:oracle:thin:@(DESCRIPTION="                   +
                         "(ADDRESS_LIST="              +
                             "(ADDRESS=(PROTOCOL=TCP)" +
                                      "(HOST=host)"    +
                                      "(PORT=port)"    +
                             ")"                       +
                         ")"                           +
                         "(CONNECT_DATA="              +
                             "(SERVICE_NAME=sid)"      +
                             "(SERVER=DEDICATED)"      +
                         ")"                           +
                       ")"
 

Now i am getting the following error:

java.sql.SQLException: invalid arguments in call

 

by: schwertnerPosted on 2004-05-03 at 00:09:22ID: 10975271

You are using the sample data and of course they will not work.
Investigate the name of the Oracle server machine, the port, the name of the service, etc.

"jdbc:oracle:thin:@(DESCRIPTION="                   +
                         "(ADDRESS_LIST="              +
                             "(ADDRESS=(PROTOCOL=TCP)" +
                                      "(HOST=Investigate name of host_machine)"    +
                                      "(PORT=1521)"    +
                             ")"                       +
                         ")"                           +
                         "(CONNECT_DATA="              +
                             "(SERVICE_NAME=-investigate_the sid)"      +
                             "(SERVER=DEDICATED)"      +
                         ")"                           +
                       ")"
 


 

by: wilma22Posted on 2004-05-03 at 21:36:37ID: 10983595

Thanks  schwertner
Did that already. This is what my code looked like:

return DriverManager.getConnection ("jdbc:oracle:thin:@(DESCRIPTION="                   +
                         "(ADDRESS_LIST="              +
                             "(ADDRESS=(PROTOCOL=TCP)" +
                                      "(HOST=192.128.116.34)"    +
                                      "(PORT=1521)"    +
                             ")"                       +
                         ")"                           +
                         "(CONNECT_DATA="              +
                             "(SERVICE_NAME=orcl)"      +
                             "(SERVER=DEDICATED)"      +
                         ")"                           +
                       ")"
);

Even tried machine name instead of IP.

 

by: wilma22Posted on 2004-05-03 at 21:38:28ID: 10983604

we are not given any user name and password in this code, like we did in previous code

Class.forName("oracle.jdbc.driver.OracleDriver");
      return DriverManager.getConnection ("jdbc:oracle:thin:@127.0.0.1:1521:orcl", "scott", "tiger");


Don't we need to mention scott/tiger anywhere?

 

by: schwertnerPosted on 2004-05-03 at 21:57:07ID: 10983648

"scott" is the user name
"tiger" is the password for this user.

Mr. Scott was the first employee of Oracle, and Tiger is the name of his cat!

In an Oracle instance  there are many user names with appropriate passwords. Each contains a set of tables.


 

by: wilma22Posted on 2004-05-04 at 01:11:12ID: 10984350

>>"scott" is the user name
"tiger" is the password for this user.

What I wanted to ask was don't we need to specify the user name and password for the scheam we are trying to log into.
The code which was posted by you doesn't have any fields for user name and password


("jdbc:oracle:thin:@(DESCRIPTION="                   +
                         "(ADDRESS_LIST="              +
                             "(ADDRESS=(PROTOCOL=TCP)" +
                                      "(HOST=192.128.116.34)"    +
                                      "(PORT=1521)"    +
                             ")"                       +
                         ")"                           +
                         "(CONNECT_DATA="              +
                             "(SERVICE_NAME=orcl)"      +
                             "(SERVER=DEDICATED)"      +
                         ")"                           +
                       ")"

It doesn't specify user name and password anywhere.

 

by: schwertnerPosted on 2004-05-06 at 01:44:27ID: 11003604

based on

("jdbc:oracle:thin:@127.0.0.1:1521:orcl", "scott", "tiger");

You have to

("jdbc:oracle:thin:@(DESCRIPTION="                   +
                         "(ADDRESS_LIST="              +
                             "(ADDRESS=(PROTOCOL=TCP)" +
                                      "(HOST=192.128.116.34)"    +
                                      "(PORT=1521)"    +
                             ")"                       +
                         ")"                           +
                         "(CONNECT_DATA="              +
                             "(SERVICE_NAME=orcl)"      +
                             "(SERVER=DEDICATED)"      +
                         ")"                           +
                         ",scott,tiger"          +
                       ")"

Details could be found in your JDBC book.

BUT I THINK the first is good enough.

127.0.0.1 as I remember is LOOPBACK IP address, i.e. the same machine.

You have to make sure the IP of the machine on which Oracle server resides.
You have to check whether you can access the machine:
C:>ping 110.30.17.124
Only after this you will be able to establish the needed connection.
If you have installed Oracle client on the server machine check if you can connect Oracle.
Using Easy Config or NET Config. Assistant make an local name connection string to the database and test it. If you succeeed to do this you will not have problems.
After you make the connection string it is easy to check the connection:
C:>tnsping string
Of course make sure that the Oracle listener and the Oracle instance are runing on the Oracle server side.




   

 

 

by: wilma22Posted on 2004-05-06 at 21:14:22ID: 11011938

>>If you have installed Oracle client on the server machine check if you can connect Oracle

Do i need to install oracle machine in the server machine or the client machine.


 

by: schwertnerPosted on 2004-05-07 at 07:20:39ID: 11015006

For the thin client - NO.
But it seems you have no access to the Oracle Server machine.
You have to check if you could see it as remote machie - use PINF command as explained above.

 

by: wilma22Posted on 2004-05-11 at 21:19:25ID: 11046737

I used the ping command and and the oracle server machine pings fine.


 

by: DarthModPosted on 2004-06-11 at 12:05:36ID: 11291646

PAQed, with points refunded (500)

DarthMod
Community Support Moderator

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...