Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Frits Walraven
Bartenders:
  • Carey Brown
  • salvin francis
  • Claude Moore

java.sql.SQLException: Io exception: The Network Adapter could not establish the connection  RSS feed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have written an simple jsp code to connect to the database and retrive some records.

In the first stage, it is giving me below error message.

" java.sql.SQLException: Io exception: The Network Adapter could not establish the connection "

I m running it on the eclipse.

Jsp code file :

<%@ page import="java.sql.*" %>
<%

try {
Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con=DriverManager.getConnection("jdbc:oracle:thin://10.26.71.17:1521/preclrty","cprg","c10");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from service_types");
%>
<% if(rs.next())
{
rs.previous();
%>
<table width="830" border="1" align="center" bordercolor="#000000">
<tr>
<td width="63" align="center"><span class="style25">Your Account Balance: <b>Rs.</b></span></td>
<%

while(rs.next())
{
%>
<td width="63" align="center"><span class="style25"><%=rs.getString(2)%></span></td>
</tr>



<%
}

}
else
{
%>

<%
}

}catch(Exception e)
{
out.println("the error is "+e);
}
%>

Note : I have removed the html tags from the file.

Can someone help help.
I m trying to learn basic programming using the JSPs, to build an front for my daily activities.

I think I have missed out some configurations.

Please help me thank you in advance.











 
Marshal
Posts: 67257
170
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you are just starting to use JSP then you need to know that you are doing it wrong. Putting Java code into a JSP is a practice that has been obsolete and discredited for 12 years now. 12 years!

You should be putting such code in Java classes and not in the JSPs.
 
dattathreya bonakurthi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bear,
I know that I m not following any architecture but I want to know the reason beyond the error displayed.
If I can resolve this one, I would be going to do it in an MVC.

In my first step, I m facing the problem.
What could be the reason for it.

If any jar files are missed by me ?

Thanks,
 
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Can you try with -



Also check for IP address of Db service its mapping present in /etc/hosts file (On Windows machine eg. - C:/Program Files/System32/Drivers/etc/hosts)

--Pras
 
dattathreya bonakurthi
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank u.
its working.
 
incandescent light gives off an efficient form of heat. You must be THIS smart to ride this ride. Tiny ad:
Create Edit Print & Convert PDF Using Free API with Java
https://coderanch.com/wiki/703735/Create-Convert-PDF-Free-Spire
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!