Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem with query

 
Beksy Kurian
Ranch Hand
Posts: 254
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 254
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I used URLEncoder and it worked
Beksy
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic