Win a copy of React Cookbook: Recipes for Mastering the React Framework this week in the HTML Pages with CSS and JavaScript forum!

Adam Haglund

Greenhorn
+ Follow
since Feb 19, 2009
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Adam Haglund

Thank you so much, I finally got everything working.

Though, I still get a nasty error in catalina.out. Should I be worrying about it, and how do I fix it?
Also, my context.xml looks exactly like in my first post.

Catalina.out coming here...

Yes, the catalina.out shows quite the same as the error message. Though, it prints the "Initializing datasource"

Here:

I added the finally clause to the function like this:



This returned an error at conn.close(); as conn is null.

I have also attached the last log entry in catalina.out to this post, maybe you could translate to english and see what is wrong
Catalina.out

To me, it still looks like a configuration problem, like if it doesnt find the database host.
I tried the code with the new catch statements. The strange thing is that it no longer returns an error at all, the page loads fine and the function returns false. (It should return true)

This is the complete code for db.java now:


I don't know if there is a way to make the function print my query, but System.out.println did not work (nothing was printed).
Though, I am pretty sure the sql is ok, because when I changed the last return to true, the whole function returned true.

Btw, the reference looked good, I have read the part about Postgresql but I don't think I have missed anything in the setup.
Hi again,
I did not get the e.printStacktrace() to work (compilation error, missing symbol), but this code compiled fine:



However, the only difference from the previous error is that the jsp error row (out.println(db.loginUser("adam","test")); ) wasn't mentioned.
Still getting this stacktrace:



The NullpointerException is still pointing to the conn.createStatement(); row.
What can I do?

Thank you for your patience.
Hi Balu and thank you for the quick reply. I changed

to

However, this did not seem to solve the problem. Error message is still the same.
Do you have any other ideas what might be wrong?
Hi guys,
I'm am currently trying to learn Java and want to connect to a Postgresql database.
I am using a simple JSP page and a bean which contains all database functions. This is set up in Tomcat and JDK/1.6.0. Everything works fine but the connection itself, for some reason it throws a null value.
I suspect that the problem is the connection configuration, in tomcat/conf/context.xml.
Connecting to the database from terminal works fine, using psql -h etc...

This is what I have:

tomcat/conf/context.xml


tomcat/webapps/ROOT/WEB-INF/web.xml


tomcat/webapps/ROOT/WEB-INF/classes/bean/db.java



tomcat/webapps/ROOT/login.jsp




Running login.jsp returns error here:


Error output:


What am I doing wrong? Help is very much appreciated.
Thank you.