• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 444
  • Last Modified:

How to configure a JNDI to get results in the jsp page?

I tried to configure the files to get a jdbc connection from jsp to rertieve data and i get the following errors. Can you help me why ....

exception

javax.servlet.ServletException: javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)"
      org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:862)
      org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
      org.apache.jsp.test.newjsp_jsp._jspService(newjsp_jsp.java:103)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


root cause

javax.servlet.jsp.JspException: Unable to get connection, DataSource invalid: "Cannot create PoolableConnectionFactory (Could not create connection to database server. Attempted reconnect 3 times. Giving up.)"
      org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.getConnection(QueryTagSupport.java:308)
      org.apache.taglibs.standard.tag.common.sql.QueryTagSupport.doStartTag(QueryTagSupport.java:192)
      org.apache.jsp.test.newjsp_jsp._jspx_meth_sql_005fquery_005f0(newjsp_jsp.java:124)
      org.apache.jsp.test.newjsp_jsp._jspService(newjsp_jsp.java:78)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:377)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:717)


check the attachment  for the source code


Can you help me on how to get access to the database and retrieve the data by using the jndi configuration ...
0
semltd
Asked:
semltd
  • 2
2 Solutions
 
DataCruncherCommented:
I can't see the source code attached to your question, could you post it again?

Also, could you confirm your web server (tomcat? which version?) and datase used (mysql?)
0
 
mrcoffee365Commented:
Googled your error message, and found one person who had this problem and fixed it with a configuration change:

You have to add following line to your $TOMCAT-CONFIG/policy.d/04webapps.policy

permission java.net.SocketPermission "127.0.0.1:3306", "connect";

However -- you should still post your code and configuration.  The above fix assumes Tomcat 6 and MySQL 5 on Unix.  YMMV
0
 
semltdAuthor Commented:
the problem was somewhere else ....  It was the jdbc connection Thank you that you try to help me anyway
0
 
semltdAuthor Commented:
I trouble shoot and find the solution by myself
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now