• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

JSP cannot connect to Oracle on remote machine

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am using JSP deployed on tomcat.
I am using the following code to connect to Oracle 8i on a different machine.
public class ConnectionManager
{
public static Connection getConnection() throws Exception
{
Class.forName("oracle.jdbc.driver.OracleDriver");
return DriverManager.getConnection ("jdbc racle:thin:@192.168.34.120:1521 rcl", "scott", "tiger");
}
}
But i am getting the following error
Network Adapter could not establish connection
Please help.
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you able to access Oracle using SQL*plus?
 
Angela lewis
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Oracle is on a remote machine, so how can i access it using SQL*plus?
But i can access it using sql*plus from the machine in which oracle is installed .
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It seems like the Database server is not properly set... Or the IP address or port you specified is wrong...
Angela, try to make sure that the database server is properly set... U may use the method that Pradeep mentioned... If you can access the database using SQL Plus, then it is working properly... Then the problem would be in your code... Hope it helps..
 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Angela,


Oracle is on a remote machine, so how can i access it using SQL*plus?


You can use SQL*Plus to make connection to Oracle server, even it is in the remote machine. What you need is an Oracle Client, and configure well with the TNSNAMES.ora file.
Nick.
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Oracle is on a remote machine, so how can i access it using SQL*plus?


You should be able to access.
Why dont you do a ping 192.168.34.120 to check if your remote m/c is in the network?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The most possible errors maybe either the IP is incorrect, or the port you are using is not the default port 1521.
Please check both.
Nick.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One more thing can be checked... you need to check whether the LISTENER has been configured and startup properly.
Since local connection does not use LISTENER, thus, you can make connections in local machine does not mean you can do the same in remote.
You can check the LISTENER config. file in:
$ORACLE_HOME/network/admin
After that, you can use lsnrcrt command to start or restart the listener.
Nick.
 
Angela lewis
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks everyone for replying.
The machine is on the network(used ping to determine this).
I can log on to Oracle using sql*plus.
Listener is also up and running.
Port is also correct because if i use the same code on the machine in which Oracle is installed it works fine(ofcourse i change the ip in that case).
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use the following instead of Class.forName(), make sure that you import the Oracle Driver.
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think that the thread should be moved to JDBC forum.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree. This is most likely a JDBC specific issue or a database configuration issue.
Possibly the database server is not set up to allow JDBC connection from the machine running the application server, or the application server is behind a firewall that lets SQL*Plus pass but not JDBC.
 
Sheriff
Posts: 67682
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moved to the JDBC forum.
 
Angela lewis
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank u so much guys for the effort.
Unable to solve the problem we installed both the oracle server and tomcat on the same machine.
Thanks a lot.
 
Ranch Hand
Posts: 211
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You do one thing.
Give this command in your SQL Plus client.Let the server be any where.
You Just Copy these 3 lines and execute.
create table ANGELA (name varchar(20));
commit;
select * from tab;
What is happening???Are u able to see ANGELA in the result???
 
Is this the real life? Is this just fantasy? Is this a tiny ad?
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic