|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
|
|
#1
|
|||||
|
|||||
|
JDBC - Retriving Information
Can anyone please tell me why I keep getting "null" as the result? please.
java Code:
__________________
IE QUOTE | PHP Manual | Google | C/C++ Compiler | Linux Tutorials | General Stuff Game Dev Last edited by xlordt : May 8th, 2008 at 01:12 AM. |
|
#2
|
||||
|
||||
|
Your code looks fine. I'd start by checking your database. Or your connection to it.
__________________
The day I get my hands on the cookbook it's all over. -nicky |
|
#3
|
||||
|
||||
|
What's the output of the print statements?
__________________
~ishnid; Have you tried: [ search.cpan.org | perldoc | Java API | mysql.com | google ] Apostrophes are NOT used for possessive pronouns or for noun plurals, including acronyms. |
|
#4
|
||||
|
||||
|
witch one? I get the done one, then I get
> null >null >done Also my database connection is fine, so its pretty weird. |
|
#5
|
||||
|
||||
|
You sure there are results in there?
If there are no results, 'execute' will return false, so your result set won't get initialised and so will remain 'null'. |
|
#6
|
||||
|
||||
|
Quote:
|
|
#7
|
||||
|
||||
|
It's been a long time since I've used MySQL, so this may or may not be correct. But Java has specific ways to execute queries and updates in addition to "execute". It may be that there's some weird (and seemingly wrong) interaction between your database, your driver, and your program.
Try using: Code:
rts = stmt.executeQuery ("select * from reps")
instead of: Code:
#
if (stmt.execute ("select * from reps"))
{
rts = stmt.getResultSet ();
}
It shouldn't make a difference, but it might. And it's certainly worth a quick test.
__________________
A -> B: Ride. The road to enlightenment is more fun on two wheels. The recent fuel price increase has had an interesting side effect. Many of the people that used to always say to me "You shouldn't ride a motorcycle, they're dangerous" are now saying "So, what kind of mileage do you get?"... |
|
#8
|
||||
|
||||
|
Quote:
|
|
#9
|
||||
|