0

can I use setObject() method of PreparedStatement for all datatypes(like string, int, double..) for Oracle database and in its OJDBC?

Possible duplicate is this :

setObject() method of PreparedStatement

But I want to know about using it for Oracle database and OJDBC. What are possible problems?

2 Answers 2

2

The possible problems are:

  1. You are delaying type validation till the application execution and don't take advantage of type safety. So you'll have errors during execution which could be easily caught at compilation time.
  2. You are loosing control of how types are inferred which might lead to weird formatting in some cases

My advise is to use setObject only if absolutely necessary.

Sign up to request clarification or add additional context in comments.

Comments

1

One problem that I came across is the ambiguity that arises in case of null values. In my application, this led to problems for the database to cache queries properly. To avoid this I had to check if the value was null and use #setNull(index, class) in these cases.

For non-null values I haven't come across any problems.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.