File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JSP cannot connect to Oracle on remote machine

 
Angela lewis
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you able to access Oracle using SQL*plus?
 
Angela lewis
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • 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 .
 
Ko Ko Naing
Ranch Hand
Posts: 3178
  • 0
  • Mark post as helpful
  • send pies
  • 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..
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • 0
  • Mark post as helpful
  • send pies
  • 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: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that the thread should be moved to JDBC forum.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the following instead of Class.forName(), make sure that you import the Oracle Driver.
 
Jeroen Wenting
Ranch Hand
Posts: 5093
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64205
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moved to the JDBC forum.
 
Angela lewis
Ranch Hand
Posts: 100
  • 0
  • Mark post as helpful
  • send pies
  • 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.
 
Mathews P Srampikal
Ranch Hand
Posts: 211
  • 0
  • Mark post as helpful
  • send pies
  • 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???
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic