Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JDBC-CONNECTION POOL

 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys,

I am unable to connect to DATABASE

This is the code I used in my Java file to get connection:



Server.xml




I downloaded jndi.jar and kept it in jre/lib/ext and even in tomcat lib also and set both class paths
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the Exception I got




My CLASSPATH variable

 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is that the complete stack trace? That looks as if the code is not running as part of a web app; is it? If not, then there will indeed not be a JNDI context to use - standalone applications don't have one unless you set it up as described in http://java.sun.com/products/jndi/tutorial/beyond/env/context.html
 
Rob Spoor
Sheriff
Pie
Posts: 20531
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JDBC
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No its is in web-application only.
Just for debugging I wrote main function and called from command prompt
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just for debugging I wrote main function and called from command prompt

You can't run it in this way outside of the container. What exception are you getting if you run it inside of a servlet container?
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator



I checked for logs files for the Exception
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I checked for logs files for the Exception

What does this mean - that there were no exceptions? If so, does the code work correctly? If not, what does it do?
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ya am not getting any error or exception.

Just my jsp page is being blank [ am using the resultset retuend contents to dispaly. Nothinh is coming in jsp page ]
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramesh Sunkara wrote:Ya am not getting any error or exception.

Just my jsp page is being blank [ am using the resultset retuend contents to dispaly. Nothinh is coming in jsp page ]

..and there is no HTML source?
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is my JSP page
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just noticed that the Java code you posted earlier contains a comment " // Here am getting Null Pointer Exception." - so are you in fact getting an exception? If so, which object is null?

Does your last post mean that the HTML page is completely blank? Of just that some parts of the JSP page that you thought should get executed are not in fact executed, and that the rest of the JSP created HTML output just fine? TellTheDetails
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"the rest of the JSP created HTML output is just fine"-- exaclty this is happening in my case.
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refer to this post here. It might be helpful for you!

http://www.coderanch.com/t/489828/Tomcat/JDBC-Exception-JNDI-lookup
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jothi Shankar,

I did coded just as you said in your link. But I cant figure out. Please help me
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramesh Sunkara wrote:"the rest of the JSP created HTML output is just fine"-- exaclty this is happening in my case.

OK, finally you're starting to tell us the details. But we still don't know if there is or is not an exception happening anywhere along the code path ... is there? If so, which one? In which line of code? If it's a NPE, which object is null? Etc. etc.
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Ulf Dittmer,

I am ready to tell all the details required. The reason why I didn't pasted all my code is I thought of giving only relevant code. So that .it saves time of who helps me.

Am not "getting any output" displayed in my JSP which I retrieved from DB. When I used plain DB conncetion without using connection pool everything worked fine.

Since I am not getting any output displayed, I checked log file tomact/logs/ I found the "NullPointerException at line:53" Which i commented in my post
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, so it looks as if the "dvr_conn" reference is null. Where (and how) are you assigning a value to that?
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another issue to ponder is that you should set up JNDI as it's described in http://tomcat.apache.org/tomcat-5.5-doc/jndi-resources-howto.html (which has no ResourceParam elements).

Also note that you're using different names for the Resource and ResourceParam elements - very confusing, to say the least, and possibly incorrect.
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Ramesh Sunkara
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Also note that you're using different names for the Resource and ResourceParam elements - very confusing, to say the least, and possibly incorrect. "

Its just typing mistake I corrected it now
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic