aspose file tools*
The moose likes JDBC and the fly likes JSP cannot connect to Oracle on remote machine Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JSP cannot connect to Oracle on remote machine" Watch "JSP cannot connect to Oracle on remote machine" New topic
Author

JSP cannot connect to Oracle on remote machine

Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
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

Joined: Feb 27, 2002
Posts: 8919

Are you able to access Oracle using SQL*plus?


Groovy
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
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

Joined: Jun 08, 2002
Posts: 3178
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..


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Nicholas Cheung
Ranch Hand

Joined: Nov 07, 2003
Posts: 4982
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.


SCJP 1.2, OCP 9i DBA, SCWCD 1.3, SCJP 1.4 (SAI), SCJD 1.4, SCWCD 1.4 (Beta), ICED (IBM 287, IBM 484, IBM 486), SCMAD 1.0 (Beta), SCBCD 1.3, ICSD (IBM 288), ICDBA (IBM 700, IBM 701), SCDJWS, ICSD (IBM 348), OCP 10g DBA (Beta), SCJP 5.0 (Beta), SCJA 1.0 (Beta), MCP(70-270), SCBCD 5.0 (Beta), SCJP 6.0, SCEA for JEE5 (in progress)
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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

Joined: Nov 07, 2003
Posts: 4982
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

Joined: Nov 07, 2003
Posts: 4982
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

Joined: Mar 01, 2004
Posts: 100
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

Joined: Feb 27, 2002
Posts: 8919

Use the following instead of Class.forName(), make sure that you import the Oracle Driver.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

I think that the thread should be moved to JDBC forum.
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
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.


42
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Moved to the JDBC forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Angela lewis
Ranch Hand

Joined: Mar 01, 2004
Posts: 100
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

Joined: Nov 26, 2002
Posts: 211
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???


Thanks,
Mathews
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JSP cannot connect to Oracle on remote machine