I am trying to write simple Java web application to get data from a database. I need to run several select queries on different database tables.
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";
And I tried to do it like this:
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();
I can only run one query with the same statement. How can I execute several queries with the same statement?