ike2010
asked on
Query error (servlets, not jsp)
I couldn't find a servlets section, so this was my best bet. Here is my problem:
I have the following code:
while(rset.next()) //rset from rset = stmt.executeQuery(nameQuer y);
{
//imagine all this on one line
out.println("<a href= \"http://localhost:8080/servlet/helpdesk.CustomerDetails?
CustName=" + rset.getString(1) + "\">" + rset.getString(1) + "</a><br>");
}
I am trying to do a db search and the results are printed out in hyperlinks as listed above. So a link might look like:
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=Visa
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=Microsoft
However, when I do my search I get the following error:
executeQuery No data found
Here's the tricky part. If I declare a variable String test = "test" and replace the first rset.getString(1) with test, the search works and i get hyperlinks that look like:
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=test
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=test
Any tips?
I have the following code:
while(rset.next()) //rset from rset = stmt.executeQuery(nameQuer
{
//imagine all this on one line
out.println("<a href= \"http://localhost:8080/servlet/helpdesk.CustomerDetails?
CustName=" + rset.getString(1) + "\">" + rset.getString(1) + "</a><br>");
}
I am trying to do a db search and the results are printed out in hyperlinks as listed above. So a link might look like:
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=Visa
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=Microsoft
However, when I do my search I get the following error:
executeQuery No data found
Here's the tricky part. If I declare a variable String test = "test" and replace the first rset.getString(1) with test, the search works and i get hyperlinks that look like:
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=test
http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=test
Any tips?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks sompol. I don't know why this is the case because I have used my original solution before. Of course that was using an ORACLE server and now I'm using MS SQL Server, so maybe that has something to do with it.
I think it depends on driver you use.
String temp = rset.getString(1);
out.println("<a href= \"http://localhost:8080/servlet/helpdesk.CustomerDetails?CustName=" + java.net.URLEncoder.encode