| Author |
Null pointer exception
|
Anand Karia
Ranch Hand
Joined: Sep 25, 2004
Posts: 154
|
|
Dear All, I am using Netbeans IDE and postgres as backend database. I have a table naming bc_scan with columns (tokenno varchar, dtime timestamp, swapmode char(1)). I have entered timestamp in dtime field When i am trying to get data on pgadmin then it shows data but when i am placing the query on my ide then it shows null pointer exception. Although it shows getFetchSize() = 1. String Sql = select dtime from bc_scan where tokenno = '01' and swapmode = '02'; Statement st = ??? so on....... ResultSet rs = st.executeQuery(sql); It Shows error on any of these. 1. rs.getString(1); 2. rs.getDate(1); 3. rs.getTimeStamp(1); 4. rs.getString(1).toString;
|
Love is GOD and GOD is Love.<br /> <br />Anand Karia<br />Manager I.T<br />Artistic Garment Ind. Pvt. Ltd<br />MSC (Computer Science)
|
 |
Brian Cole
Author
Ranch Hand
Joined: Sep 20, 2005
Posts: 852
|
|
Originally posted by Anand Karia: String Sql = select dtime from bc_scan where tokenno = '01' and swapmode = '02'; Statement st = ??? so on....... ResultSet rs = st.executeQuery(sql); It Shows error on any of these. 1. rs.getString(1); 2. rs.getDate(1); 3. rs.getTimeStamp(1); 4. rs.getString(1).toString;
Do you ever call rs.next()? btw, it probably would have made more sense to post your question to the JDBC forum, as it doesn't have any Swing/AWT/SWT/JFace content.
|
bitguru blog
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Forgetting to call rs.next() should not result in an NPE but an SQLException instead.
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
Ilja Preuss
author
Sheriff
Joined: Jul 11, 2001
Posts: 14112
|
|
1.-3. cannot possibly throw a NPE, unless the JDBC driver has a bug (quite unlikely). It would probably help if you showed us the true code and the stack trace.
|
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
|
 |
Anand Karia
Ranch Hand
Joined: Sep 25, 2004
Posts: 154
|
|
Dear All First i would like to inform you that rs.next() is already written. Finally when i change my jdbc driver from old one to new one then it show me correct result. But this is really imazing that one form is getting result without any error from same old jdbc driver and another form is not. If i found any solution that why this problem has occur then i will definately post it here, if opssible. Anyhow my this problem have been solved out through changing of jdbc driver. Thank you all.
|
 |
 |
|
|
subject: Null pointer exception
|
|
|