Every one knows that PreparedStatement is prepared once, and the precompiled version of the query is stored in the Database. (That means SQL syntax parsing done only once at the time of preparation)
If i am creating two different PreparedStstement object with the same query.
Is the second object uses the precompiled query (created by the first one) Or Both query will be parsed by the SQL parser and created a two precompiled version of query in the Database.
'typically' the same query will only be compiled once, but the exact behaviour is dependent on the database. I understand Oracle matches the query String, so you should ensure they are the same.
Oh, and it is also the case that a database can discard these precompiled queries to save room, so even exact matches can be compiled in the DB multiple times. I have never worried about it too much though.