Problems with (PreparedStatement prest) in retrieving data from the database
query="select friend_uname from myfriends";//SELECT ALL THE FRIENDS OF THE USER
System.out.println(query);
rs=stmt.executeQuery(query);
query="select * from service_provider where source=\""+source+"\" and dest=\""+dest+"\" and resources>0 and provider_name IN(?);";
System.out.println(query);
prest=conn.prepareStatement(query);
while(rs.next())
{
x=rs.getString("friend_uname");//SELECT THE FRIEND NAMES OF THE USER ONE BY ONE...
System.out.println("THE friend_uname IS"+ x);
prest.setString(1,x);//SET T开发者_C百科HE iTH POSITION OF THE STRING AS THE FRIEND NAME
}
try this query
query="select * from service_provider where source=\""+source+"\" and dest=\""+dest+"\" and resources>0 and provider_name IN(select friend_uname from myfriends)";
or try with the join query
query="select sp.* from service_provider sp, myfriends myfrnd where sp.source=\""+source+"\" and sp.dest=\""+dest+"\" and sp.resources>0 and sp.provider_name=myfrnd.friend_uname";
精彩评论