Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Select Statement and other

 
Gloria Hans
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two problems that I've been trying to solve for a week without getting any result.
1. I am having an unclosed string literal error when I run my select query. ResultSet rs = s.executeQuery(sql); I am not sure how I am supposed to close this string. Can you please help.
String sql = "SELECT Pro.ProjectNumber, Pro.ProjectSubject, Pro.SeniorResearcher, Entry.EntryDesc, Pro.Status, Pro.SDate, Pro.EDate +
FROM Pro INNER JOIN Entry ON Pro.EntryType = Entry.EntryType
WHERE Entry.EntryDesc='"+ c +"' + And Pro.Status='"+st+"'+ ORDER BY id desc";
When I only have something like :
"select * FROM Pro WHERE Status = '" +st+"'";
It works. But the more complex one doesn't work and I am trying to create a kind of report out of that query.
Please help.
2. I am creating a table and want to add links into it.
In my jsp page I have
<%
out.println("<TR>");
out.println("<td>"+projectNum+"</td>");
out.println("<td>"+subject+"</td>");
out.println("<td>"+title+"</td>");
out.println( "</TR>" );
%>
I've been really unsuccessfull adding a link to this. I can use this
<td><%= projectNum%></td>
<td><%=title%></td>
then it's possible to add links into it but it's only print one row.My list of data doesn't show

Please urgent help beofore christmas break. This will be my christmas present from you if you help me.
 
Tim Baker
Ranch Hand
Posts: 541
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for your first problem you seem to have three erroneus + characters in your SQL statement.
String sql = "SELECT Pro.ProjectNumber, Pro.ProjectSubject, Pro.SeniorResearcher, Entry.EntryDesc, Pro.Status, Pro.SDate, Pro.EDate +
FROM Pro INNER JOIN Entry ON Pro.EntryType = Entry.EntryType
WHERE Entry.EntryDesc='"+ c +"' + And Pro.Status='"+st+"' + ORDER BY id desc";
you should remove those 3
as for point two i'm not sure what you mean by adding a link, please can you explain more
ps highlighting didnt seem to work so i've put a face next to each one
[ December 11, 2003: Message edited by: Tim Baker ]
 
Chad McGowan
Ranch Hand
Posts: 265
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For your first problem:
String sql = "SELECT Pro.ProjectNumber, Pro.ProjectSubject, Pro.SeniorResearcher, Entry.EntryDesc, Pro.Status, Pro.SDate, Pro.EDate +
FROM Pro INNER JOIN Entry ON Pro.EntryType = Entry.EntryType
WHERE Entry.EntryDesc='"+ c +"' + And Pro.Status='"+st+"'+ ORDER BY id desc";
should be:

 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64607
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Since this is much more about JDBC/SQL I'm moving this to the JDBC forum.
bear
 
Gloria Hans
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried this:
String sql = "SELECT Pro.ProjectNumber, Pro.ProjectSubject, Pro.SeniorResearcher, Entry.EntryDesc, Pro.Status, Pro.SDate, Pro.EDate +
FROM Pro INNER JOIN Entry ON Pro.EntryType = Entry.EntryType
WHERE Entry.EntryDesc='"+ c +"' + And Pro.Status='"+st+"'+ ORDER BY id desc";
It's returning a blank page with an error on the tomcat console incorrect syntax near the keyword iNNER.

What wrong near the INNER join keyword??
 
Jamie Robertson
Ranch Hand
Posts: 1879
MySQL Database Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
as stated above, you need to get rid of the erroneous + characters in your query string.
after removing these + signs you should have something like this:
String sql = "SELECT Pro.ProjectNumber, Pro.ProjectSubject, Pro.SeniorResearcher, Entry.EntryDesc, Pro.Status, Pro.SDate, Pro.EDate
FROM Pro INNER JOIN Entry ON Pro.EntryType = Entry.EntryType
WHERE Entry.EntryDesc='"+ c +"' And Pro.Status='"+st+"' ORDER BY id desc";
give that a try and see if it bombs out.
If it does bomb out, post the SQLException message here
Jamie
[ December 12, 2003: Message edited by: Jamie Robertson ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic