Reputation: 1929
PreparedStatement preparedStatement = connection.prepareStatement(sql);
preparedStatement.setString(1, "Gary");
preparedStatement.setString(2, "Larson");
preparedStatement.setLong (3, 123);
'preparedStatement' is an object. But how can we call it as an object if it doesn't use the new operator?
Upvotes: 0
Views: 42
Reputation: 198103
Sure it uses the new
operator, it just uses new
somewhere inside the implementation of prepareStatement
. That's just calling another method that does the new
ing for you. That's actually a super common pattern called the factory pattern.
Upvotes: 4