Paul,
I read your kind suggestion. However, if you could just play around with connection, ResultSet and PrepareStatement closing, you'd realise that your opinion could be ....
Well, I tried closing the conection also as said in code below. But I am still able to execute the query.
Ideally speaking, If i have closed the connection, PrepareStatement should not get execute.
Session session = null;
PreparedStatement ps = null;
ResultSet rs = null;
try {
Configuration configuration = new Configuration();
SessionFactory sessionFactory = configuration.configure().buildSessionFactory();
session = sessionFactory.openSession();
String query = "select * from trade";
Connection connection = session.connection();
ps = connection.prepareStatement(query);
connection.close(); //Inspite of this line, the lines below are working fine!!
rs = ps.executeQuery();
int i=0;
while (rs.next()) {
i++;
}
System.out.println("rs_size="+i);
System.out.println("Done");
} catch (Exception e) {
System.out.println("Exception..."+e.getMessage());
e.printStackTrace();
}
Please advice.
