Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Jsp databse connectivity problem

 
Satish Kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends ,
I am new to jsp programming and i am actually stuck up at a small point of my jsp programe.
I was actually doing a jsp prog that would connect to oracle databse and retrieve the data and show it back to the user. But when i execute it i get this error
------------------------------------------------------------------------------- -------------------------------------
javax.servlet.ServletException: Unable to get connection, DataSource invalid: "java.sql.SQLException: Io exception: The Network Adapter could not establish the connection"
------------------------------------------------------------------------------- --------------------------------------
The databse is also residing on my own system i.e on my localhost , i m not connecting to any remote server .I have set the environmental variable "classpath" to classes12.jar and also placed in lib folder of my project .But i still get the above error. The platform i use is tomcat 5.5 , operating system as windows XP and oracle 9i as my database.
I would be very eagerly awaiting for any reply as its a lil urgent .

Thank you in advance,
Satish
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its a JDBC question.

- What driver are you using.
- Post some code snippet.
 
Satish Kumar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
heres the code , i m giving only the tag file
====================================================

<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ attribute name="ID" required="true" %>


<sql:setDataSource
var="LoginData"
driver="oracle.jdbc.driver.OracleDriver"
url="jdbc racle:thin:@localhost:1521:SATISH"
user="scott"
password="tiger"
/>
<sql:query dataSource="${LoginData}" var="l_results"

sql="SELECT * FROM LOGIN WHERE U_ID=${ID}" />
<c:forEach var="row" items="${l_results.rows}">
<c ut value="${row.PASS}" />
</c:forEach>
<c ut value="~" />
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sounds like your DB is on remote machine.
Are you able to access the DB via some other client like, SQL Plus, TOAD, Aqua Data Studio?
 
rahul V kumar
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you make sure you have got the entry for the database in tnsnames.ora
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by rahul V kumar:
Can you make sure you have got the entry for the database in tnsnames.ora


No, if you are using oracle thin driver, then you dont need to configure tnsnames. You can use SID of the DB instead.
Thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic