wood burning stoves 2.0*
The moose likes JDBC and the fly likes JDBC-CONNECTION POOL Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC-CONNECTION POOL" Watch "JDBC-CONNECTION POOL" New topic
Author

JDBC-CONNECTION POOL

Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
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

Joined: Mar 01, 2010
Posts: 78
This is the Exception I got




My CLASSPATH variable

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
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


Ping & DNS - my free Android networking tools app
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19649
    
  18

Moving to JDBC


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
No its is in web-application only.
Just for debugging I wrote main function and called from command prompt
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
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

Joined: Mar 01, 2010
Posts: 78



I checked for logs files for the Exception
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
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

Joined: Mar 01, 2010
Posts: 78
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

Joined: Apr 14, 2004
Posts: 10336

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?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78


This is my JSP page
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
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

Joined: Mar 01, 2010
Posts: 78
"the rest of the JSP created HTML output is just fine"-- exaclty this is happening in my case.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9344
    
    2

Refer to this post here. It might be helpful for you!

http://www.coderanch.com/t/489828/Tomcat/JDBC-Exception-JNDI-lookup


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
Hi Jothi Shankar,

I did coded just as you said in your link. But I cant figure out. Please help me
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
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

Joined: Mar 01, 2010
Posts: 78
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
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
OK, so it looks as if the "dvr_conn" reference is null. Where (and how) are you assigning a value to that?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41034
    
  43
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

Joined: Mar 01, 2010
Posts: 78
Ramesh Sunkara
Ranch Hand

Joined: Mar 01, 2010
Posts: 78
"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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC-CONNECTION POOL
 
Similar Threads
JMS, WebSphere, JNDI = Nightmare
Exception while connectiing DB through Tomcat
Is this true: JNDI equals Connection Pooling
Tomcat Connection Pooling Help required
DBCP Problems