• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

jsp db query

Hi, experts,

I have a table called listFiles. There is a field called authorName in the table. The application is following.
In a html form, user select an author name, submit it into a jsp file. In the jsp file I used  :

selectStmt=sqlConn.prepareStatement("SELECT fileName, authorName, submDate from listFiles WHERE authorName=?");
selectStmt.setString(1, authorNames);
sqlRst=selectStmt.executeQuery();

My question is: for example, the name user want to know is "abc", if the author "abc" has submitted a file before, there will be a query reqult.

but if the author "abc" hasn't submited a file, then there will not be a name called "abc" in the database.  in this situation, how to do the query ?

Thanks for your reply.
0
lilyyan
Asked:
lilyyan
  • 5
  • 4
  • 4
  • +2
1 Solution
 
bloodredsunCommented:
>>but if the author "abc" hasn't submited a file, then there will not be a name called "abc" in the database.  in this situation, how to do the query ?

Just do the query and then test whether your resultset has any results, if it's false then you have no values

e.g.

if ( rs.next() == false )
0
 
bloodredsunCommented:
in your case:

if ( sqlRst.next() == false )
0
 
KuldeepchaturvediCommented:
how you can get to a question in less than 4 mins bloodred?????...:-)
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

 
TimYatesCommented:
I'm guessing he's got a case of the "Friday F5's" ;-)

hehehe..

Speaking of which, I've got a can of beer in the fridge at home, which I can hear calling my name... ;-)
0
 
KuldeepchaturvediCommented:
this is friday and in UK it should be already time to go home...!!!! you shd just shut down the machine and hit the motorway..!!!
0
 
TimYatesCommented:
Hehehe...every time I go to leave, I get a new "Comment Added" email in my gmail wiindow ;-)

Bah!
0
 
KuldeepchaturvediCommented:
speaking of comments..

http://www.experts-exchange.com/Web/Web_Languages/JSP/Q_21390788.html this one is kinda failing me..!! never worked with DB2 before..
see if your eyes catches something....thanks..!!
0
 
bloodredsunCommented:
>> how you can get to a question in less than 4 mins bloodred?????...:-)

I wrote a little app called HTMLAlert that scans EE every 5 mins and pops up a little Swing window telling me what the new question is called and in which TA. Tim's got a copy but I think he's been too busy (lazy?!) to use it. There's a better one available if you use Windows, so email me at my profile address and I'll give you a copy if you like.

Anyway, you should be out on the town as it's late o'clock in India, Kuli not answering EE questions!

Happy Friday all :-)

0
 
koppchaCommented:
Guys you are tooooooo fast
Even before i take a look at the question they are around 7 posts.(I am refreshing this page every now and then)
0
 
KuldeepchaturvediCommented:
>>>
town as it's late o'clock in India
As of nowI am in Columbia South Carolina USA.. so its start of the friday not end of it...(sigh!!!!)..
can you email me this HTMLAlert at kuldeep.kuldeepchaturvedi@gmail.com..!!
that wd be awesome...
0
 
koppchaCommented:
Hi Bloodredsun
   I tried to send an email to you at this address brs@bloodredsun.com but it got bounced can you give me your email address.
0
 
koppchaCommented:
this is mine chanduraju_iit@yahoo.com
0
 
bloodredsunCommented:
Steady boys, lets not over-run this thread... Right I'll do that and contact you both but for future reference I don't think that emails in threads is a good idea. :-(

Let's knock this on the head and let Lilyan get on with her db coding :-)
0
 
lilyyanAuthor Commented:
Fantastic ! hehehe :)
0
 
bloodredsunCommented:
Thanks lilyan, sorry about your thread being taken over like that, I promise we'll be good in the future ;-) !!!!!!
0
 
koppchaCommented:
I apologize for that
0
 
lilyyanAuthor Commented:
That's fine. It's a kind of fun actually. hehehe ;-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

  • 5
  • 4
  • 4
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now