PublicListgetAll1 (Stringname) throwsException {ListresultnewArrayList (); ConnectionconDatabaseConnection. getConnection (); Stringnanull; Stringsql1 & quot; select * fromguanzhuwhereguanzhu? & Quot; PreparedStatementps1con. prepareS java database mysql computer jsp
Public ListgetAll1 (String name) throws Exception {
Listresult = new ArrayList ();
Connection con = DatabaseConnection. getConnection ();
String na = null;
String sql1 = "select * from guanzhu where guanzhu =? ";
PreparedStatement ps1 = con. prepareStatement (sql1 );
Ps1.setString (1, name );
ResultSet rs1 = ps1.executeQuery ();
While (rs1.next ()){
Connection con1 = DatabaseConnection. getConnection ();
Na = rs1.getString ("beiguanzhu ");
String SQL = "select * from message where author =? Order by modified desc "; PreparedStatement ps = con1.prepareStatement (SQL );
Ps. setString (1, na); ResultSet rs = ps.exe cuteQuery ();
While (rs. next ()){
Message m = new Message ();
M. setId (rs. getInt ("id "));
M. setTitle (rs. getString ("title "));
M. setContent (rs. getString ("content "));
M. setModified (rs. getDate ("modified "));
M. setAuthor (rs. getString ("author "));
Result. add (m );
System. out. println (rs. getString ("author") + "");
}
}
Return result;
}