[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

jsp db query

Posted on 2005-04-22
17
Medium Priority
?
229 Views
Last Modified: 2010-04-01
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
Comment
Question by:lilyyan
  • 5
  • 4
  • 4
  • +2
17 Comments
 
LVL 29

Accepted Solution

by:
bloodredsun earned 400 total points
ID: 13843890
>>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
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13843915
in your case:

if ( sqlRst.next() == false )
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 13843936
how you can get to a question in less than 4 mins bloodred?????...:-)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 35

Expert Comment

by:TimYates
ID: 13843947
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
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 13843965
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
 
LVL 35

Expert Comment

by:TimYates
ID: 13843982
Hehehe...every time I go to leave, I get a new "Comment Added" email in my gmail wiindow ;-)

Bah!
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 13843999
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
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13844084
>> 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
 
LVL 8

Expert Comment

by:koppcha
ID: 13844097
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
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 13844131
>>>
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
 
LVL 8

Expert Comment

by:koppcha
ID: 13844256
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
 
LVL 8

Expert Comment

by:koppcha
ID: 13844259
this is mine chanduraju_iit@yahoo.com
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13844365
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
 

Author Comment

by:lilyyan
ID: 13844448
Fantastic ! hehehe :)
0
 
LVL 29

Expert Comment

by:bloodredsun
ID: 13844476
Thanks lilyan, sorry about your thread being taken over like that, I promise we'll be good in the future ;-) !!!!!!
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13844481
I apologize for that
0
 

Author Comment

by:lilyyan
ID: 13844559
That's fine. It's a kind of fun actually. hehehe ;-)
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Often times it's very very easy to extend a volume on a Linux instance in AWS, but impossible to shrink it. I wanted to contribute to the experts-exchange community a way of providing a procedure that works on an AWS instance. It can also be used on…
Last month Marc Laliberte, WatchGuard’s Senior Threat Analyst, contributed reviewed the three major email authentication anti-phishing technology standards: SPF, DKIM, and DMARC. Learn more in part 2 of the series originally posted in Cyber Defense …
Loops Section Overview
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses

873 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question