File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes how to make java database connectivity with oracle 10g on windows vista operating system. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "how to make java database connectivity with oracle 10g on windows vista operating system." Watch "how to make java database connectivity with oracle 10g on windows vista operating system." New topic
Author

how to make java database connectivity with oracle 10g on windows vista operating system.

yashpal waghmare
Greenhorn

Joined: Sep 17, 2008
Posts: 22
I am not able nto make jdbc connectivity with oracle 10g on windows vista operating system, I have done following code for that, I have put comment at line where its giving an error.

TreeMap loginMap = new TreeMap();
Connection con = null;
ResultSet rs= null;
Statement st =null;
String query = null;

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

String url = "jdbcracle:thin:@123.236.165.26:1521rcl";// its giving error at this line
con = DriverManager.getConnection(url);

st = con.createStatement();

query="select user_name, user_password from TrainRes_user_tbl";






Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Errors contain information about the cause of the problem. You know, once cause is understood, a solution is clear.

But you didn't post any details about the error, thus we can't give/explain any solution. Please post the details.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874

Exactly as Bauke said and dont post the same question in multiple forum as we never know where to answer your query.

yashpal waghmare
Greenhorn

Joined: Sep 17, 2008
Posts: 22

Hi , now i have changed that line which is giving an error to,

TreeMap loginMap = new TreeMap();
Connection con = null;
ResultSet rs= null;
Statement st =null;
String query = null;

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



String url = "jdbc:oracle:thin:@123.236.165.26:1521:orcl";// its giving error at this line

con = DriverManager.getConnection(url);

st = con.createStatement();

query="select user_name, user_password from TrainRes_user_tbl";





And The error is:

13:14:53,209 ERROR [STDERR] java.sql.SQLException: Io exception: The Network Adapter could not establish the connection
13:14:53,210 ERROR [STDERR] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
13:14:53,210 ERROR [STDERR] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
13:14:53,210 ERROR [STDERR] at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:255)
13:14:53,210 ERROR [STDERR] at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:387)
13:14:53,210 ERROR [STDERR] at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:439)
13:14:53,211 ERROR [STDERR] at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:165)
13:14:53,211 ERROR [STDERR] at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:35)
13:14:53,211 ERROR [STDERR] at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:801)
13:14:53,211 ERROR [STDERR] at java.sql.DriverManager.getConnection(Unknown Source)
13:14:53,211 ERROR [STDERR] at java.sql.DriverManager.getConnection(Unknown Source)
13:14:53,211 ERROR [STDERR] at Model.TrainReservationModel.getloginMap(TrainReservationModel.java:63)
13:14:53,211 ERROR [STDERR] at Action.ActionTrainReservation.getLogin(ActionTrainReservation.java:54)
13:14:53,211 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
13:14:53,211 ERROR [STDERR] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
13:14:53,211 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
13:14:53,212 ERROR [STDERR] at java.lang.reflect.Method.invoke(Unknown Source)
13:14:53,212 ERROR [STDERR] at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:276)
13:14:53,212 ERROR [STDERR] at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:196)
13:14:53,212 ERROR [STDERR] at org.apache.struts.actions.MappingDispatchAction.execute(MappingDispatchAction.java:171)
13:14:53,212 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
13:14:53,212 ERROR [STDERR] at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:226)
13:14:53,212 ERROR [STDERR] at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1164)
13:14:53,212 ERROR [STDERR] at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:415)
13:14:53,212 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
13:14:53,212 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
13:14:53,212 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
13:14:53,212 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
13:14:53,212 ERROR [STDERR] at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
13:14:53,212 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
13:14:53,212 ERROR [STDERR] at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
13:14:53,212 ERROR [STDERR] at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
13:14:53,212 ERROR [STDERR] at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
13:14:53,212 ERROR [STDERR] at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:179)
13:14:53,212 ERROR [STDERR] at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:84)
13:14:53,212 ERROR [STDERR] at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
13:14:53,213 ERROR [STDERR] at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
13:14:53,213 ERROR [STDERR] at org.jboss.web.tomcat.service.jca.CachedConnectionValve.invoke(CachedConnectionValve.java:156)
13:14:53,213 ERROR [STDERR] at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
13:14:53,213 ERROR [STDERR] at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:241)
13:14:53,213 ERROR [STDERR] at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
13:14:53,213 ERROR [STDERR] at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:580)
13:14:53,213 ERROR [STDERR] at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
13:14:53,213 ERROR [STDERR] at java.lang.Thread.run(Unknown Source)
yashpal waghmare
Greenhorn

Joined: Sep 17, 2008
Posts: 22
Hi Balu,
Thanks for guiding me, I have given error what I am getting.

Thanks in Advance.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
yashpal waghmare wrote:
String url = "jdbc:oracle:thin:@123.236.165.26:1521:orcl";// its giving error at this line
This can't have thrown the SQLException. Read the stacktrace until the first line of your class:

13:14:53,211 ERROR [STDERR] at Model.TrainReservationModel.getloginMap(TrainReservationModel.java:63)

It's line 63 of Model.TrainReservationModel class, inside the getLoginMap() method, which threw the SQLException. Apart from this, you should respect the Java Naming Conventions. Package names should be all in lowercase. Otherwise it look like an inner class in the stacktrace.

Back to the actual exception:
java.sql.SQLException: Io exception: The Network Adapter could not establish the connection

The DB server cannot be connected in any way. This can have several causes:
1) URL (host/ip/port) is wrong.
2) Database is down.
3) Database doesn't accept TCP/IP connections.
4) Firewall/router is blocking the connections.
Balu Sadhasivam
Ranch Hand

Joined: Jan 01, 2009
Posts: 874


13:14:53,209 ERROR [STDERR] java.sql.SQLException: Io exception: The Network Adapter could not establish the connection



This usually occurs when your DataBase is not listening the connection at 1521 . Make sure your DB is running. You can login to the DB machine using SQL* plus and check if its running.

Also the other problem may be with the SID ( instance name) , make sure that you are using the available instance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to make java database connectivity with oracle 10g on windows vista operating system.