Results 1 to 8 of 8
- 06-25-2008, 08:11 AM #1
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
[SOLVED] General string problem in my database query.....?
Hi Members,
String query = "Select * from table1 join table2 on tb1 = tb2 join table3 on tb2 = tb3 where tb1.id = 2 and tb2.name= 'john' and tb3.descriptionId=5";
This is my string but when i compile and run this im not getting any result for this query, so i made a system.print for this string query and my print statements looks like this:
"Select * from table1 join table2 on tb1 = tb2 join table3 on tb2 = tb3 where tb1.id = 2 and tb2.name= 'john
' and tb3.descriptionId=5".
Please have a look at this in my WHERE class that tb2.name, and if i join the 2nd line and 3rd line, im getting the result for my query; but im not sure why it is acting so.
Please help me out in this....
Looking forward for your reply..
Regards,
Prabhu.
- 06-25-2008, 08:17 AM #2
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
What you mean the 2nd line and 3rd line. Only I can see one line there.
- 06-25-2008, 08:33 AM #3
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
Hi Eranga,
Great to see you again, in my query you can see it in two lines, in that my 1st line ends with "tb2.name='john " can you see that and the ending "single cotes...... ' " is continued in the second line..... can you see that......
1st line: Select * from table1 join table2 on tb1 = tb2 join table3 on tb2 = tb3 where tb1.id = 2 and tb2.name= 'john
2nd line: ' and tb3.descriptionId=5"
As string should be within ' ' single cotes, using mysql.....
Can you get me Eranga....
If not please let me know...
Regards,
Prabhu.
- 06-25-2008, 08:40 AM #4
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
Why don't you try like this.
Java Code:String query = "Select * from table1 join table2 on tb1 = tb2 join table3 on tb2 = tb3 " + "where tb1.id = 2 and tb2.name= 'john' and tb3.descriptionId=5""
- 06-25-2008, 08:43 AM #5
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
How can we do so? It will throw "unclose string literal" error?
Before I got the same problem then i renamed my method name and then compiled and ran it, it was fine, but now again i face this problem.
Regards,
Prabhu.
- 06-25-2008, 08:46 AM #6
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
So my friend, simply close it. I made a little mistake there.
Java Code:String query = "Select * from table1 join table2 on tb1 = tb2 join table3 on tb2 = tb3 " + "where tb1.id = 2 and tb2.name= 'john' and tb3.descriptionId=5";
- 06-25-2008, 08:54 AM #7
Member
- Join Date
- May 2008
- Posts
- 69
- Rep Power
- 0
Hi Friend,
Sorry i have made some mistakes, the parameter which im passing to WHERE class has some extra space, so now i tried using "trim()" and everything works fine.
Will meet you on next post.
FYI,
I have posted a topic related to 'struts 2 help...' are you watching it buddy. Please I need seniors like you to help me on that.
Thank you,
Prabhu.
- 06-25-2008, 08:55 AM #8
- Join Date
- Jul 2007
- Location
- Colombo, Sri Lanka
- Posts
- 11,374
- Blog Entries
- 1
- Rep Power
- 18
If you solve this please mark the thread solved.
And....
Similar Threads
-
Java Popup Window & Url Query String Value
By Rivelyn in forum New To JavaReplies: 4Last Post: 01-20-2011, 05:03 AM -
Query in database
By anki1234 in forum JDBCReplies: 3Last Post: 08-20-2008, 05:45 PM -
ms access jdbc query problem
By Fleur in forum New To JavaReplies: 2Last Post: 04-30-2008, 06:55 PM -
How to query data from database using SSL
By mano in forum New To JavaReplies: 0Last Post: 08-02-2007, 05:30 PM -
Displaying different columns with database query
By jennybgh in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 08-02-2007, 05:04 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks