aspose file tools*
The moose likes JDBC and the fly likes Select Statement and other Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Select Statement and other" Watch "Select Statement and other" New topic
Author

Select Statement and other

Gloria Hans
Greenhorn

Joined: Nov 06, 2003
Posts: 18
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

Joined: Oct 04, 2003
Posts: 541
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 ]

Kim Jong II (North Korea's Dear Leader) said:Nuclear weapons don't kill people, people kill people.
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
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

Joined: Jan 10, 2002
Posts: 61437
    
  67

Since this is much more about JDBC/SQL I'm moving this to the JDBC forum.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Gloria Hans
Greenhorn

Joined: Nov 06, 2003
Posts: 18
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

Joined: Jul 09, 2001
Posts: 1879

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 ]
 
Consider Paul's rocket mass heater.
 
subject: Select Statement and other