簡單點理解:prepareStatement會形成參數化的查詢,例如:
1
select * from A where tablename.id = ?
傳入參數'1;select * from B'如果不經過prepareStatement,會形成下面語句:
1
select * from A where tablename.id = 1;select * from B
這樣等於兩次執行,但如果經過預處理,會是這樣:
1
select * from A where tablename.id = '1;select * from B'
'1;select * from B'只是一個參數,不會改變原來的語法