• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

saving sql query to string[]

 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I basically want to display results from a SQL query to a simple website... I have my querey but when I try i to on my website i get no results and no erros...

This is my code



I cant figure why I am not able to display...the result in my DB is a list of names (50+)
Can anybody help!!
THANK YOU
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Step 1: if the DB access code is in a JSP, move it out to a Java class. First. Now. Before doing anything else.

Then test the class separately to make sure that it's doing what you expect it to do.

After that, you can call this class from your page controller and forward the List of results to the JSP for display.
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
that shouldnt make a difference... If the code is right, it should work!!
Obviously there is something wrong in my code, because on my previous pages i have no problem
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eduardo Ponce de Leon wrote:that shouldnt make a difference... If the code is right, it should work!!

Indeed it should. But since it doesn't work, it isn't right.

Does your debugger support JSPs?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One of the very very very many reasons not to put Java code in a JSP is testability. You can choose to take the advice of the senior members and follow best practices. Or you can continue to struggle. The choice is yours.
 
Eduardo Ponce de Leon
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
to be hones i dont know if my DB access is in JSP. Yes i want to take advantage of your knowledge...
this is my code, what is next?

 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Eduardo Ponce de Leon wrote:to be hones i dont know if my DB access is in JSP.


I'm sorry, am I correct in assuming that you don't know whether that code you posted is a JSP? Then yes, I can confirm that it's JSP code.

What should you do next? Well, JSP is an extremely poor environment for debugging code. Get your database code out of that JSP and put it into a plain old Java class. Get it working there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic