• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unable to Retrieve values

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
These are my two files to enter data into database and retrieve data from database.
I am able to enter the data into database but not able to retrieve the data from database.
What may be the reason ?? What is my mistake ?
Can anybody help me ?? Waiting for kind reply.
Thank you in advance.



HTML File







java file
 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

PreparedStatement ps;
Statement st = null;
ResultSet rs = null;


rs = st.executeQuery("SELECT * FROM student");
} catch (SQLException e) {



The statement is not initalized so you will get null pointer exception.

try to use con.createStatement to initalize the statment
 
rajnish patel
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bala nannaka wrote:

PreparedStatement ps;
Statement st = null;
ResultSet rs = null;


rs = st.executeQuery("SELECT * FROM student");
} catch (SQLException e) {



The statement is not initalized so you will get null pointer exception.

try to use con.createStatement to initalize the statment




Can you please explain me ??
(please give that portion of coding for me also.)
As I am abeginner I want to know the reason for getting Nullpointer exception in this.
So please explain me or give me any link so that I can learn from that.

by the way, thank you so much for reply.
 
rajnish patel
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Either con.createstatement is not working for me or I dont know how to add it..

Please help me to do that.
 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi

before this line " rs = st.executeQuery("SELECT * FROM student"); " can you add

st=con.createStatement();

then it will work.

Thanks
 
rajnish patel
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Suresh babua wrote:Hi

before this line " rs = st.executeQuery("SELECT * FROM student"); " can you add

st=con.createStatement();

then it will work.

Thanks




Thank you so much. Problem is solved.

Thank you all of above who helped me.
 
Why fit in when you were born to stand out? - Seuss. Tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic