您好,我想在 jsp 文件中传递我的两个 ResultSet。我有两个 ResultSet rs 和 rs1。我已将两个 ResultSet 都存储在单个数组中。现在我想在 jsp 文件中打印该数组。所以我可以在网页上显示我的结果。请告诉我应该在 jsp 文件中编写哪些代码。我应该在jsp文件中导入多少文件..请帮助我。
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con= (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/lportal","root","ubuntu123");
PreparedStatement stmt = (PreparedStatement) con.prepareStatement("SELECT * FROM Testi_Testimonial where subject = ?");
PreparedStatement stmt1 = (PreparedStatement) con.prepareStatement("SELECT * FROM Testi_Testimonial where subject != ?");
stmt.setString(1,search);
stmt.execute();
rs=(ResultSet) stmt.getResultSet();
stmt1.setString(1,search);
stmt1.execute();
rs1=(ResultSet) stmt1.getResultSet();
while(rs.next())
{
count++;
anArray[i]=rs.getString("subject");
System.out.println(anArray[i]);
i++;
}
while(rs1.next())
{
anArray[i]=rs1.getString("subject");
System.out.println(anArray[i]);
i++;
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("problem in connection");
}
这是我的 Java 代码,其中包含结果集和数组。请帮助我。