我正在尝试编写简单的 Java Web 应用程序来从数据库中获取数据。我需要在不同的数据库表上运行几个选择查询。
String queryOne = "select firstname from employees where empid = id";
String queryOne = "select title from books where bookid = bid";
String queryOne = "select auther from books where bookid = bid";
我试着这样做:
Connection connection = dataSource.getConnection();
Statement statement = connection.createStatement();
ResultSet rs1 = statement.executeQuery(queryOne);
while (rs1.nest()) {
String firstName = rs1.getString(1);
}
statement.close();
connection.close();
我只能使用相同的语句运行一个查询。如何使用相同的语句执行多个查询?