Win a copy of Succeeding with AI this week in the Artificial Intelligence and Machine Learning forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
  • Junilu Lacar
Sheriffs:
  • Tim Cooke
  • Jeanne Boyarsky
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • salvin francis
  • fred rosenberger
  • Frits Walraven

Unable to Retrieve values

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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.
 
I think he's gonna try to grab my monkey. Do we have a monkey outfit for this tiny ad?
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic