This is my code.
Code 1 : StringBuilder sb = new StringBuilder("select * from user");
Code 2 : StringBuffer sb1 = new StringBuffer("select * from user");
Which one is correct? and Why?
EDIT : I have seen in some code StringBuffer is used and in other StringBuilder is used. For the query like this, which will be passed to get PreparedStatement, which approach is better. Also tell me what would happen for insert queries.