I am working on a java application and using Derby Database.
I have one object of PreparedStatement named pstmt.
1) Can I use same object (here pstmt) for every SELECT Statements like these and others Statements (Would it be an efficient way) ?
For Ex:
pstmt = conn.prepareStatement("SELECT NAME FROM TABLE1 ORDER BY NAME");
pstmt = conn.prepareStatement("SELECT * FROM TABLE1 ORDER BY NAME");
pstmt = conn.prepareStatement("SELECT * FROM TABLE1 WHERE .....");
or I have to create different objects per different SQL Statement like below..
pstmt1 = conn.prepareStatement("SELECT NAME FROM TABLE1 ORDER BY NAME");
pstmt2 = conn.prepareStatement("SELECT * FROM TABLE1 ORDER BY NAME");
pstmt3 = conn.prepareStatement("SELECT * FROM TABLE1 WHERE .....");
2) And what about other Statements like CREATE, INSERT, UPDATE etc. Can I use a common object for each type of operation (like one object for every SELECT Statements, one for every INSERT, one for UPDATE Statements and so on..)
I know the advantages of it but I am confused with efficient usage of it.