• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to Retrieve values

 
rajnish patel
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
 
bala nannaka
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.
 
asr chowdary
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic