Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!

Angus McIntosh

Greenhorn
+ Follow
since Jan 28, 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 Angus McIntosh

I feel silly

I was editing the hibernate.cfg.xml in my sources directory and not the one in my classes directory.

Sorry for wasting your time!
I don't understand where this exception comes from!

This is my hibernate.cfg.xml



and then I get this from my webapp when I try to persist:



But I don't see a "value" attribute anywhere to complain about!

Help me please!
If so, do you have it set up to highlight EL? Nothing I've come across so far manages this.
Thanks!

#1 is what I went with.
11 years ago
JSP
This was driving me nuts! After extensive googling, I at least know now that Java 5 enums are not supported by the JSTL standard, but that still leaves me with an enum to iterate over.

So, I have an Enum called Levels, which has getLevelName(), getAltLevelName() and getOrdinal() methods (if I can remove the getOrdinal() method and just use the regular ordinal() method I'd be happy!).

What I'd love to do is:



Of course this won't work, but is there a way to iterate over this Enum without cheating (i.e. resorting to scriptlets)?
11 years ago
JSP
I must not understand the output of jdb, because what Bauke Sholtz suggested fixed my problem.

Thanks a lot!
I pretty much just lifted it from Horstmann & Cornell's Core Java Vol 2.



and this is database.properties

Paul Sturrock wrote:As Jeanne has already said, the ResultSet should not be null. Which Driver are you using?



I'm using mysql-connector-java-5.1.6, the one in the Intrepid repositories. I'm able to INSERT in another part of my app with it. But when I run the above code, I get a null object, and my test code crashes with a NullPointerException.

Also, why are you closing your results set in the same loop you use to iterate through it?



I'm not, I'm closing it in the _if_ block, although I suppose it would make more sense to close it outside the if block.

Avyaya Avi wrote:You NEED to call rs.next() in order to enter the result set values anyway.


That' what I thought!

What I suggest may be lame, but consider once and do let me know.

Move



to the top and execute.



It doesn't make a difference, but thanks!

It seems I bumped 14 seconds after you posted! And here I though I was being neglected!

Jeanne Boyarsky wrote:Angus,
Welcome to JavaRanch!


Thank you!


When you say the result set is null, do you mean empty? A result set should never be null.


I mean that the ResultSet object itself is null (according to jdb). But no exception is thrown by st.executeQuery ().

So even if I remove the first rs.next () statement, I still get a NullPointerException. (but don't you have to call next() to access the first record?)



In my webapp (an educational games database), I can add games to the database no problem, but I can't access the set of games once they're there.
Using jdb with the following class, I found that st.executeQuery (GAMES_LIST_QUERY) is returning null. No exceptions are thrown, and the class seems to be connecting properly with the database.
When I run the exact same query in mysql on the cli, though, I get the results I want (I cut and pasted, just to be sure).