String query="UPDATE table_name SET tab_attr1= ? WHERE tab_attr2= ?";
PreparedStatement preparedStatement=connection.prepareStatement(query);
preparedStatement.setString(1,"test1");
preparedStatement.setString(2,"test2");
//case_1
int count=preparedStatement.executeUpdate();
/*
case_2
preparedStatement.execute();
int count=preparedStatement.getUpdateCount();
*/
進出口新的領域,作爲一個Java開發工作不使用UpdateCount()和executeUpdate的()的返回samething
在我的測試用例都返回同樣的事情 所以我的問題是,是否有任何區別兩個 如果沒有差異,那麼這兩個函數的需求是什麼。 2例..有什麼區別?
從「Statement」接口Javadoc,這兩個方法看起來很相似:https://docs.oracle.com/javase/7/docs/api/java/sql/Statement.html –
無論出於何種原因,我已經看到'executeUpdate()'被更頻繁地使用。 –