Re: ClientPreparedQueryBindings setInt method convert int directly to byte array
Posted by: chen yi
Date: December 21, 2021 09:33PM

Hi Filipe
Yes we changed ClientPreparedQueryBindings to ServerPreparedQueryBinding and solved above problem.

I want to ask another question.

first we want to do following code optimization.

ThreadLocal<Calendar> calendar = ThreadLocal.withInitial(() -> Calendar.getInstance(US));

ResultSet rs = stmt.executeQuery();
byte[] bytes = rs.getBytes(column);
java.util.Date date = toDate(bytes, calendar.get());

if directly invoke rs.getDate(column, calendar.get());
we found that getDate method internally invoked calendar.clone(); we want to avoid that clone invocation.

but we can't ensure the protocol type of `bytes` object, it might be text protocol or binary protocol.
for now we write a method to get protocol type

public boolean isBinary(ResultSet v) throws SQLException {
return (v != null) && (v.getStatement() instanceof PreparedStatement);

I want to ask is there a easy way to get the protocol type or specify client protocol type?

Options: ReplyQuote

Sorry, only registered users may post in this forum.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.