aspose file tools*
The moose likes Servlets and the fly likes problem with query Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem with query" Watch "problem with query" New topic
Author

problem with query

Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
I have a query like this:
myRs = myStmt.executeQuery("SELECT id,txt_file FROM table_name WHERE rowid LIKE '" + afileID + "%'");
It works in most cases(AAABBGGAAA) except when the rowid has a value something like this
AAABBGG+AAAA(notice the + sign)
Any way to solve this?
I tried this:
String txtSql = "SELECT id,txt_file FROM table_name WHERE rowid LIKE '" + afileID + "%' ";
myRs = myStmt.executeQuery(txtSql);
It did not work.
and even this:
myRs = myStmt.executeQuery(txtSql.toString());
A fast reply appreciated
Beksy
Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
An update! the query is like this
String txtSql = "SELECT id,txt_file FROM table_name WHERE rowid = '" + afileID +"'" ;
I tried to print the query using out.println
It is displaying like this:
SELECT id,txt_file FROM table_name WHERE rowid='AAAFFBB BGG'
The '+' sign is missing and a 'space' is included.
And an error in the browser: Invalid rowid
Please help!
Beksy
Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
Looks like problem is that request.getParameter is not bringing the correct rowid. the url i am getting is as below.
/servlet/LoginServlet?pageID=rptdet&fileId=AAAF5WAAHAAAAD+AAF
This is how it is processed... and used it in the above query
String fileID =request.getParameter("fileId");
System.out.println(fileID);
this prints as AAAF5WAAHAAAD AAF
How do we parse it properly so that it won't lose the '+' sign?
Beksy
Beksy Kurian
Ranch Hand

Joined: Jul 11, 2001
Posts: 254
I used URLEncoder and it worked
Beksy
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem with query