Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting stuck up at Preparestatement.

 
Dhiren Dash
Greenhorn
Posts: 7
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the code that I am working on presently.


Everythime I execute, I get stuck up at the line, "ps1 = connect.prepareStatement("....");

I don' t know where am I going wrong.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think

should be


The quotes aren't needed around a bind variable.

I don't think that's the problem here. When you say "stuck up", do you mean the code hangs? Does it get stuck on the first attempt?

I also notice that the catch block closes resources in the wrong order. The PreparedStatement should be closed before the Connection.
 
Dhiren Dash
Greenhorn
Posts: 7
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it gets hung up. It should return the boolean value to an HRController servlet. But the thing is, it doesn' t get updated and hangs on that prepreStatement line. I just don' t know why. I used the debug on server option in eclipse. It goes upto the prepareStatement line and after that a class not found error comes up.

And yes I have included the JDBC class into my project. Before updating the record, I do displaying(fetching) records successfully.
 
Dhiren Dash
Greenhorn
Posts: 7
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have attached the error that I get in the Debug perspective.
Error.jpg
[Thumbnail for Error.jpg]
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ok. Let's try to make this simpler. If you change the SQL to this (and comment out the three set statements, does this work?


If so, that rules out a hung connection. Then add one parameter back at a time and let us know which fails.
 
Paul Clapham
Sheriff
Posts: 21567
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dhiren Dash wrote: I used the debug on server option in eclipse. It goes upto the prepareStatement line and after that a class not found error comes up.


Well, the picture you posted only says that the source code for one of the Oracle driver classes isn't available. Which isn't an error at all, it's normal. So if that's the problem that's holding you up, then just stop using debug mode. Or step out of that class and let execution carry on.

 
Dhiren Dash
Greenhorn
Posts: 7
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


It hangs in this one too. I had already tried this. It hangs all the time.
 
King Ofjava
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
have you got error in your eclipse console ?. please share that console screenshots.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with Paul that it is probably a debugging issue. Can you run your program using "run as" rather than "debug as"? And clear all breakpoints?
 
Dhiren Dash
Greenhorn
Posts: 7
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I was doing that earlier. Finally I got fed up and decided to run the program in Debug mode and see where the bug is.

But the good news is, now its working. I made another PreparedStatement object "ps2" and used that instead. Although I don' t know if that matters or not. Because I had closed all the other instances of the PreparedStatement object "ps1" properly in the finally block in all the previous methods using "ps1". Also, I closed eclipse and restarted it again. And now its working. Weird stuff.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic