Lilli Consult database operation problems ..

Category: Web Develop
 
shangshang1986
2010-07-29 08:15:38

Sponsored Links
I was in a JSP page to pass String Username = request.getParameter ("username"); Gets the user name .. and then spread to a class to do processing
search mgr = new search ( );
c = mgr.getAllMessages (Username);

JAVA class as database query String sql = "select * from Article where AUTHOR = '"+ Username +"' ";

but does not normally return results.
I ask why????

Sponsored Links

ruanshunqing
2010-07-29 08:35:31
everyone Help me ah ~ ~ ~
meritzhao111
2010-07-29 08:54:16
String Username = request.getParameter ("username");

print what Username values ​​look
wlddhj
2010-07-29 09:10:28
c = mgr.getAllMessages (Username);

String sql = "select * from Article where AUTHOR = '" + Username + " '"; That is what your c Yeah, what is your pass here

paste your code look

sandaoshahu
2010-07-29 09:16:16
print normal ah ...
C is to obtain an array lookup database collection ..

rs = stmt.executeQuery (sql);
Collection c = new ArrayList ();
messageA msg = null;
while (rs.next ()) {
msg = new messageA ();
msg.seta_id (rs.getInt ("ID"));
msg.seta_title (rs.getString ("TITLE"));
msg.seta_content (rs.getString ("CONTENT"));
msg.setAuthor (rs.getString ("AUTHOR"));

c.add (msg);
msg = null;
} return c;
yanjiushengyingyu
2010-07-29 09:29:43
trouble you help me see ... I have studied for a long time will not work ah ...
powerballoon
2010-07-29 09:44:07
is not a garbage problem:
String Username = new String (request.getParameter ("username"). getBytes ("ISO8859_1"), "gb2312");
zkliruipeng
2010-07-29 10:00:00
return any results ah
Domain and server ip had changed since 8/23/2013. Suspend the user registration and posts for program maintenance.