File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Prepared Statement  trouble Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Prepared Statement  trouble" Watch "Prepared Statement  trouble" New topic
Author

Prepared Statement trouble

Tom Shypulski
Greenhorn

Joined: Jan 02, 2009
Posts: 8
I apologize in advance if I did not post this in the correct forum. I'm having trouble getting my prepared statement to execute properly. I have tried creating the SELECT query many different ways this is just one of them. When this method is called it prints out string from System.out.println("BEfore DB call. " + pg + " " + perPg); in my console then drops out with no data returned. In fact it appears my code cannot reach System.out.println("After DB call. "); output. I cannot get the query to execute properly.

Any help would be greatly appreciated.



Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Your code is throwing a SQLException. What is it.?
Tom Shypulski
Greenhorn

Joined: Jan 02, 2009
Posts: 8
Hmm. I see no SQLException in my eclispe console it only returns test data System.out.. . The method call returns to a servlet. When I test in my browser it drops back to servlet (http://localhost/servlet/coreservlets.WebAppsServlet?pages=1&linksPerPage=5) and displays blank screen. It should return the data to servlet and depening on what it contains redirect to one of two JSP pages.
Tom Reilly
Rancher

Joined: Jun 01, 2010
Posts: 618
Your method throws SQLException so somewhere in your stack, it's eating it. I suggest you catch SQLException and log the error. Or you can check your log files.
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

have you tried writing the query in an SQL client first?
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2503
    
    8

You can bind variables into a query. The parameters you pass to the LIMIT clause aren't variables. They cannot be bound.


OCUP UML fundamental and ITIL foundation
youtube channel
 
jQuery in Action, 2nd edition
 
subject: Prepared Statement trouble