As You said it was not working.. The Records have been inserted after executing the code.... I am Using Oracle thin driver....I think whenever we don't give commit or rollback and closing the connection smoothly,
the cached transactions are getting commited even though we set AutoCommit as false...
I tried the following three code sections. In the first one when I used conn.commit(), the changes got committed. I verified that by firing the select query in database from pl/sql developer. In case of second and third code sections changes were not persistent and were not committed.