Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

clearBatch method not support in iAnywhere JDBC driver?

8 posts in General Discussion Last posting was on 2009-04-10 14:57:12.0Z
Bill Williams Posted on 2009-04-07 14:37:09.0Z
From: "Bill Williams" <billwilliams@qcsoftware.com>
Newsgroups: ianywhere.public.general
Subject: clearBatch method not support in iAnywhere JDBC driver?
Lines: 15
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49db6515@forums-1-dub>
Date: 7 Apr 2009 07:37:09 -0700
X-Trace: forums-1-dub 1239115029 10.22.241.152 (7 Apr 2009 07:37:09 -0700)
X-Original-Trace: 7 Apr 2009 07:37:09 -0700, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7485
Article PK: 5899

ASA 10.0.1 build 3835

It appears the iAnywhere JDBC driver does support batch operations, yet
since I am getting a not implemented exception, it must not support the
clearBatch method. Why is this?

In my code I am using a PreparedStatement for batch statements and always
want to clear the batch statement after it has been executed in preparation
to adding new batch updates to the same statement. Is this bad practice?

Thanks

Bill


Karim Khamis [Sybase iAnywhere] Posted on 2009-04-07 14:58:32.0Z
From: "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com>
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: clearBatch method not support in iAnywhere JDBC driver?
References: <49db6515@forums-1-dub>
In-Reply-To: <49db6515@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49db6a18$1@forums-1-dub>
Date: 7 Apr 2009 07:58:32 -0700
X-Trace: forums-1-dub 1239116312 10.22.241.152 (7 Apr 2009 07:58:32 -0700)
X-Original-Trace: 7 Apr 2009 07:58:32 -0700, vip152.sybase.com
Lines: 31
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7486
Article PK: 5900


Bill Williams wrote:
> ASA 10.0.1 build 3835
>
> It appears the iAnywhere JDBC driver does support batch operations, yet
> since I am getting a not implemented exception, it must not support the
> clearBatch method. Why is this?
>
> In my code I am using a PreparedStatement for batch statements and always
> want to clear the batch statement after it has been executed in preparation
> to adding new batch updates to the same statement. Is this bad practice?
>
> Thanks
>
> Bill
>
>

Bill,

The iAnywhere JDBC driver supports batch operations with
PreparedStatements. The driver does not support batch operations with
Statement objects. The Statement.clearBatch() method is used to clear
the list of SQL statements of a Statement batch operation. In the case
of PrearedStatements, there is only one SQL statement and executing
clearBatch is not well defined in this case. Note again that the
clarBatch method is specifically for Statements not PreparedStatements.
The best practice for prepared statements is to issue a new call to
Connection.prepareStatement thereby freeing up any resources uses by the
old prepared statement and old batch and reinitializing the
PreparedStatement object.

Karim


Bill Williams Posted on 2009-04-07 17:06:13.0Z
From: "Bill Williams" <billwilliams@qcsoftware.com>
Newsgroups: ianywhere.public.general
References: <49db6515@forums-1-dub> <49db6a18$1@forums-1-dub>
Subject: Re: clearBatch method not support in iAnywhere JDBC driver?
Lines: 44
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49db8805$1@forums-1-dub>
Date: 7 Apr 2009 10:06:13 -0700
X-Trace: forums-1-dub 1239123973 10.22.241.152 (7 Apr 2009 10:06:13 -0700)
X-Original-Trace: 7 Apr 2009 10:06:13 -0700, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7487
Article PK: 5901

If that's the way it has to be, then I guess I have to change my code but
I'm sorry, this still does not make sense to me. To execute the batch, I'm
using the executeBatch statement which is specified in Statement, not
PreparedStatement. If I'm going to close and re-open a statement, I don't
see any advantage to using a PreparedStatement.

Anyway, I do appreciate the info.

"Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
news:49db6a18$1@forums-1-dub...
> Bill Williams wrote:
>> ASA 10.0.1 build 3835
>>
>> It appears the iAnywhere JDBC driver does support batch operations, yet
>> since I am getting a not implemented exception, it must not support the
>> clearBatch method. Why is this?
>>
>> In my code I am using a PreparedStatement for batch statements and always
>> want to clear the batch statement after it has been executed in
>> preparation to adding new batch updates to the same statement. Is this
>> bad practice?
>>
>> Thanks
>>
>> Bill
>>
>>
> Bill,
>
> The iAnywhere JDBC driver supports batch operations with
> PreparedStatements. The driver does not support batch operations with
> Statement objects. The Statement.clearBatch() method is used to clear the
> list of SQL statements of a Statement batch operation. In the case of
> PrearedStatements, there is only one SQL statement and executing
> clearBatch is not well defined in this case. Note again that the clarBatch
> method is specifically for Statements not PreparedStatements. The best
> practice for prepared statements is to issue a new call to
> Connection.prepareStatement thereby freeing up any resources uses by the
> old prepared statement and old batch and reinitializing the
> PreparedStatement object.
>
> Karim


Karim Khamis [Sybase iAnywhere] Posted on 2009-04-07 17:43:29.0Z
From: "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com>
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: clearBatch method not support in iAnywhere JDBC driver?
References: <49db6515@forums-1-dub> <49db6a18$1@forums-1-dub> <49db8805$1@forums-1-dub>
In-Reply-To: <49db8805$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49db90c1$1@forums-1-dub>
Date: 7 Apr 2009 10:43:29 -0700
X-Trace: forums-1-dub 1239126209 10.22.241.152 (7 Apr 2009 10:43:29 -0700)
X-Original-Trace: 7 Apr 2009 10:43:29 -0700, vip152.sybase.com
Lines: 72
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7488
Article PK: 5903

Bill,

When you create a Statement object, you do so without specifying any
SQL. When you use Statement.addBatch() you add SQL statements to the
batch. Executing Statement.executeBatch() sends the batched SQL
statements to the server, while executing Statement.clearBatch() deletes
all the batched SQL statements and sets the Statement object in an
initialized state with no SQL attached to it. The iAnywhere JDBC driver
does not support batches with Statement objects.

Now, when you create a PreparedStatement object, you do so with a
specific SQL statement that may or may not have parameter markers.
Calling PreparedStatent.clearBatch() does not make sense since you
cannot have a PreparedStatement with no SQL statement attached. The main
reason for using a PreparedStatement is so that you do not have to
re-prepare the same SQL statement with the same set of parameter markers
every time you execute it. Calling PreparedStatement.addBatch() adds a
new row of parameters to the batch and calling
PreparedStatement.executeBatch() sends the batched parameter rows to the
server in one go and clears out all the batched parameters. If you now
want to batch up a new set of parameter rows you can do so without
re-preparing the PreparedStatment, BUT, if you want to use a completely
new SQL statement with a new set of parameter markers, then there is no
choice but to re-prepare the PreparedStatement. The iAnywhere JDBC
driver does support batches with PreparedStatement objects.

Karim

Bill Williams wrote:
> If that's the way it has to be, then I guess I have to change my code but
> I'm sorry, this still does not make sense to me. To execute the batch, I'm
> using the executeBatch statement which is specified in Statement, not
> PreparedStatement. If I'm going to close and re-open a statement, I don't
> see any advantage to using a PreparedStatement.
>
> Anyway, I do appreciate the info.
>
> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
> news:49db6a18$1@forums-1-dub...
>> Bill Williams wrote:
>>> ASA 10.0.1 build 3835
>>>
>>> It appears the iAnywhere JDBC driver does support batch operations, yet
>>> since I am getting a not implemented exception, it must not support the
>>> clearBatch method. Why is this?
>>>
>>> In my code I am using a PreparedStatement for batch statements and always
>>> want to clear the batch statement after it has been executed in
>>> preparation to adding new batch updates to the same statement. Is this
>>> bad practice?
>>>
>>> Thanks
>>>
>>> Bill
>>>
>>>
>> Bill,
>>
>> The iAnywhere JDBC driver supports batch operations with
>> PreparedStatements. The driver does not support batch operations with
>> Statement objects. The Statement.clearBatch() method is used to clear the
>> list of SQL statements of a Statement batch operation. In the case of
>> PrearedStatements, there is only one SQL statement and executing
>> clearBatch is not well defined in this case. Note again that the clarBatch
>> method is specifically for Statements not PreparedStatements. The best
>> practice for prepared statements is to issue a new call to
>> Connection.prepareStatement thereby freeing up any resources uses by the
>> old prepared statement and old batch and reinitializing the
>> PreparedStatement object.
>>
>> Karim
>
>


Bill Williams Posted on 2009-04-07 18:37:31.0Z
From: "Bill Williams" <billwilliams@qcsoftware.com>
Newsgroups: ianywhere.public.general
References: <49db6515@forums-1-dub> <49db6a18$1@forums-1-dub> <49db8805$1@forums-1-dub> <49db90c1$1@forums-1-dub>
Subject: Re: clearBatch method not support in iAnywhere JDBC driver?
Lines: 85
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49db9d6b$1@forums-1-dub>
Date: 7 Apr 2009 11:37:31 -0700
X-Trace: forums-1-dub 1239129451 10.22.241.152 (7 Apr 2009 11:37:31 -0700)
X-Original-Trace: 7 Apr 2009 11:37:31 -0700, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7489
Article PK: 5904

After I thought about it, the PreparedStatement is what I would use anyway
because we use place holder parameters (duh).

I did not realize the batch parameters are cleared after the executeBatch is
called. I guess the problem is we are not guaranteed how other software
such as Oracle, Microsoft and other vendors code their implementations of
these methods. At the moment, I'm going to go ahead and just close the
statement so I don't have to worry about it.

Thanks

"Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
news:49db90c1$1@forums-1-dub...
> Bill,
>
> When you create a Statement object, you do so without specifying any SQL.
> When you use Statement.addBatch() you add SQL statements to the batch.
> Executing Statement.executeBatch() sends the batched SQL statements to the
> server, while executing Statement.clearBatch() deletes all the batched SQL
> statements and sets the Statement object in an initialized state with no
> SQL attached to it. The iAnywhere JDBC driver does not support batches
> with Statement objects.
>
> Now, when you create a PreparedStatement object, you do so with a specific
> SQL statement that may or may not have parameter markers. Calling
> PreparedStatent.clearBatch() does not make sense since you cannot have a
> PreparedStatement with no SQL statement attached. The main reason for
> using a PreparedStatement is so that you do not have to re-prepare the
> same SQL statement with the same set of parameter markers every time you
> execute it. Calling PreparedStatement.addBatch() adds a new row of
> parameters to the batch and calling PreparedStatement.executeBatch() sends
> the batched parameter rows to the server in one go and clears out all the
> batched parameters. If you now want to batch up a new set of parameter
> rows you can do so without re-preparing the PreparedStatment, BUT, if you
> want to use a completely new SQL statement with a new set of parameter
> markers, then there is no choice but to re-prepare the PreparedStatement.
> The iAnywhere JDBC driver does support batches with PreparedStatement
> objects.
>
> Karim
> Bill Williams wrote:
>> If that's the way it has to be, then I guess I have to change my code but
>> I'm sorry, this still does not make sense to me. To execute the batch,
>> I'm using the executeBatch statement which is specified in Statement, not
>> PreparedStatement. If I'm going to close and re-open a statement, I
>> don't see any advantage to using a PreparedStatement.
>>
>> Anyway, I do appreciate the info.
>>
>> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
>> news:49db6a18$1@forums-1-dub...
>>> Bill Williams wrote:
>>>> ASA 10.0.1 build 3835
>>>>
>>>> It appears the iAnywhere JDBC driver does support batch operations, yet
>>>> since I am getting a not implemented exception, it must not support the
>>>> clearBatch method. Why is this?
>>>>
>>>> In my code I am using a PreparedStatement for batch statements and
>>>> always want to clear the batch statement after it has been executed in
>>>> preparation to adding new batch updates to the same statement. Is this
>>>> bad practice?
>>>>
>>>> Thanks
>>>>
>>>> Bill
>>>>
>>>>
>>> Bill,
>>>
>>> The iAnywhere JDBC driver supports batch operations with
>>> PreparedStatements. The driver does not support batch operations with
>>> Statement objects. The Statement.clearBatch() method is used to clear
>>> the list of SQL statements of a Statement batch operation. In the case
>>> of PrearedStatements, there is only one SQL statement and executing
>>> clearBatch is not well defined in this case. Note again that the
>>> clarBatch method is specifically for Statements not PreparedStatements.
>>> The best practice for prepared statements is to issue a new call to
>>> Connection.prepareStatement thereby freeing up any resources uses by the
>>> old prepared statement and old batch and reinitializing the
>>> PreparedStatement object.
>>>
>>> Karim
>>


Karim Khamis [Sybase iAnywhere] Posted on 2009-04-07 20:04:37.0Z
From: "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com>
User-Agent: Thunderbird 2.0.0.21 (Windows/20090302)
MIME-Version: 1.0
Newsgroups: ianywhere.public.general
Subject: Re: clearBatch method not support in iAnywhere JDBC driver?
References: <49db6515@forums-1-dub> <49db6a18$1@forums-1-dub> <49db8805$1@forums-1-dub> <49db90c1$1@forums-1-dub> <49db9d6b$1@forums-1-dub>
In-Reply-To: <49db9d6b$1@forums-1-dub>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49dbb1d5$1@forums-1-dub>
Date: 7 Apr 2009 13:04:37 -0700
X-Trace: forums-1-dub 1239134677 10.22.241.152 (7 Apr 2009 13:04:37 -0700)
X-Original-Trace: 7 Apr 2009 13:04:37 -0700, vip152.sybase.com
Lines: 93
X-Authenticated-User: techsupp
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7490
Article PK: 5902

Bill,

Just a suggestion, I believe if you were to call
PreparedStatement.executeBatch() followed by
PreparedStatement.clearParameters(), you should be fine regardless of
the specific implementation of executeBatch().

Karim

Bill Williams wrote:
> After I thought about it, the PreparedStatement is what I would use anyway
> because we use place holder parameters (duh).
>
> I did not realize the batch parameters are cleared after the executeBatch is
> called. I guess the problem is we are not guaranteed how other software
> such as Oracle, Microsoft and other vendors code their implementations of
> these methods. At the moment, I'm going to go ahead and just close the
> statement so I don't have to worry about it.
>
> Thanks
>
> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
> news:49db90c1$1@forums-1-dub...
>> Bill,
>>
>> When you create a Statement object, you do so without specifying any SQL.
>> When you use Statement.addBatch() you add SQL statements to the batch.
>> Executing Statement.executeBatch() sends the batched SQL statements to the
>> server, while executing Statement.clearBatch() deletes all the batched SQL
>> statements and sets the Statement object in an initialized state with no
>> SQL attached to it. The iAnywhere JDBC driver does not support batches
>> with Statement objects.
>>
>> Now, when you create a PreparedStatement object, you do so with a specific
>> SQL statement that may or may not have parameter markers. Calling
>> PreparedStatent.clearBatch() does not make sense since you cannot have a
>> PreparedStatement with no SQL statement attached. The main reason for
>> using a PreparedStatement is so that you do not have to re-prepare the
>> same SQL statement with the same set of parameter markers every time you
>> execute it. Calling PreparedStatement.addBatch() adds a new row of
>> parameters to the batch and calling PreparedStatement.executeBatch() sends
>> the batched parameter rows to the server in one go and clears out all the
>> batched parameters. If you now want to batch up a new set of parameter
>> rows you can do so without re-preparing the PreparedStatment, BUT, if you
>> want to use a completely new SQL statement with a new set of parameter
>> markers, then there is no choice but to re-prepare the PreparedStatement.
>> The iAnywhere JDBC driver does support batches with PreparedStatement
>> objects.
>>
>> Karim
>> Bill Williams wrote:
>>> If that's the way it has to be, then I guess I have to change my code but
>>> I'm sorry, this still does not make sense to me. To execute the batch,
>>> I'm using the executeBatch statement which is specified in Statement, not
>>> PreparedStatement. If I'm going to close and re-open a statement, I
>>> don't see any advantage to using a PreparedStatement.
>>>
>>> Anyway, I do appreciate the info.
>>>
>>> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
>>> news:49db6a18$1@forums-1-dub...
>>>> Bill Williams wrote:
>>>>> ASA 10.0.1 build 3835
>>>>>
>>>>> It appears the iAnywhere JDBC driver does support batch operations, yet
>>>>> since I am getting a not implemented exception, it must not support the
>>>>> clearBatch method. Why is this?
>>>>>
>>>>> In my code I am using a PreparedStatement for batch statements and
>>>>> always want to clear the batch statement after it has been executed in
>>>>> preparation to adding new batch updates to the same statement. Is this
>>>>> bad practice?
>>>>>
>>>>> Thanks
>>>>>
>>>>> Bill
>>>>>
>>>>>
>>>> Bill,
>>>>
>>>> The iAnywhere JDBC driver supports batch operations with
>>>> PreparedStatements. The driver does not support batch operations with
>>>> Statement objects. The Statement.clearBatch() method is used to clear
>>>> the list of SQL statements of a Statement batch operation. In the case
>>>> of PrearedStatements, there is only one SQL statement and executing
>>>> clearBatch is not well defined in this case. Note again that the
>>>> clarBatch method is specifically for Statements not PreparedStatements.
>>>> The best practice for prepared statements is to issue a new call to
>>>> Connection.prepareStatement thereby freeing up any resources uses by the
>>>> old prepared statement and old batch and reinitializing the
>>>> PreparedStatement object.
>>>>
>>>> Karim
>


Bill Williams Posted on 2009-04-08 14:24:34.0Z
From: "Bill Williams" <billwilliams@qcsoftware.com>
Newsgroups: ianywhere.public.general
References: <49db6515@forums-1-dub> <49db6a18$1@forums-1-dub> <49db8805$1@forums-1-dub> <49db90c1$1@forums-1-dub> <49db9d6b$1@forums-1-dub> <49dbb1d5$1@forums-1-dub>
Subject: Re: clearBatch method not support in iAnywhere JDBC driver?
Lines: 99
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5512
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5579
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Message-ID: <49dcb3a2$1@forums-1-dub>
Date: 8 Apr 2009 07:24:34 -0700
X-Trace: forums-1-dub 1239200674 10.22.241.152 (8 Apr 2009 07:24:34 -0700)
X-Original-Trace: 8 Apr 2009 07:24:34 -0700, vip152.sybase.com
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7492
Article PK: 5905

Thanks for the suggestion.

"Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
news:49dbb1d5$1@forums-1-dub...
> Bill,
>
> Just a suggestion, I believe if you were to call
> PreparedStatement.executeBatch() followed by
> PreparedStatement.clearParameters(), you should be fine regardless of the
> specific implementation of executeBatch().
>
> Karim
> Bill Williams wrote:
>> After I thought about it, the PreparedStatement is what I would use
>> anyway because we use place holder parameters (duh).
>>
>> I did not realize the batch parameters are cleared after the executeBatch
>> is called. I guess the problem is we are not guaranteed how other
>> software such as Oracle, Microsoft and other vendors code their
>> implementations of these methods. At the moment, I'm going to go ahead
>> and just close the statement so I don't have to worry about it.
>>
>> Thanks
>>
>> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
>> news:49db90c1$1@forums-1-dub...
>>> Bill,
>>>
>>> When you create a Statement object, you do so without specifying any
>>> SQL. When you use Statement.addBatch() you add SQL statements to the
>>> batch. Executing Statement.executeBatch() sends the batched SQL
>>> statements to the server, while executing Statement.clearBatch() deletes
>>> all the batched SQL statements and sets the Statement object in an
>>> initialized state with no SQL attached to it. The iAnywhere JDBC driver
>>> does not support batches with Statement objects.
>>>
>>> Now, when you create a PreparedStatement object, you do so with a
>>> specific SQL statement that may or may not have parameter markers.
>>> Calling PreparedStatent.clearBatch() does not make sense since you
>>> cannot have a PreparedStatement with no SQL statement attached. The main
>>> reason for using a PreparedStatement is so that you do not have to
>>> re-prepare the same SQL statement with the same set of parameter markers
>>> every time you execute it. Calling PreparedStatement.addBatch() adds a
>>> new row of parameters to the batch and calling
>>> PreparedStatement.executeBatch() sends the batched parameter rows to the
>>> server in one go and clears out all the batched parameters. If you now
>>> want to batch up a new set of parameter rows you can do so without
>>> re-preparing the PreparedStatment, BUT, if you want to use a completely
>>> new SQL statement with a new set of parameter markers, then there is no
>>> choice but to re-prepare the PreparedStatement. The iAnywhere JDBC
>>> driver does support batches with PreparedStatement objects.
>>>
>>> Karim
>>> Bill Williams wrote:
>>>> If that's the way it has to be, then I guess I have to change my code
>>>> but I'm sorry, this still does not make sense to me. To execute the
>>>> batch, I'm using the executeBatch statement which is specified in
>>>> Statement, not PreparedStatement. If I'm going to close and re-open a
>>>> statement, I don't see any advantage to using a PreparedStatement.
>>>>
>>>> Anyway, I do appreciate the info.
>>>>
>>>> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
>>>> news:49db6a18$1@forums-1-dub...
>>>>> Bill Williams wrote:
>>>>>> ASA 10.0.1 build 3835
>>>>>>
>>>>>> It appears the iAnywhere JDBC driver does support batch operations,
>>>>>> yet since I am getting a not implemented exception, it must not
>>>>>> support the clearBatch method. Why is this?
>>>>>>
>>>>>> In my code I am using a PreparedStatement for batch statements and
>>>>>> always want to clear the batch statement after it has been executed
>>>>>> in preparation to adding new batch updates to the same statement. Is
>>>>>> this bad practice?
>>>>>>
>>>>>> Thanks
>>>>>>
>>>>>> Bill
>>>>>>
>>>>>>
>>>>> Bill,
>>>>>
>>>>> The iAnywhere JDBC driver supports batch operations with
>>>>> PreparedStatements. The driver does not support batch operations with
>>>>> Statement objects. The Statement.clearBatch() method is used to clear
>>>>> the list of SQL statements of a Statement batch operation. In the case
>>>>> of PrearedStatements, there is only one SQL statement and executing
>>>>> clearBatch is not well defined in this case. Note again that the
>>>>> clarBatch method is specifically for Statements not
>>>>> PreparedStatements. The best practice for prepared statements is to
>>>>> issue a new call to Connection.prepareStatement thereby freeing up any
>>>>> resources uses by the old prepared statement and old batch and
>>>>> reinitializing the PreparedStatement object.
>>>>>
>>>>> Karim
>>


Breck Carter [TeamSybase] Posted on 2009-04-10 14:57:12.0Z
From: "Breck Carter [TeamSybase]" <NOSPAM__breck.carter@gmail.com>
Newsgroups: ianywhere.public.general
Subject: Re: clearBatch method not support in iAnywhere JDBC driver?
Organization: RisingRoad Professional Services
Reply-To: NOSPAM__breck.carter@gmail.com
Message-ID: <1dnut4li20isn3ir4986ahrdt1ohgaasdm@4ax.com>
References: <49db6515@forums-1-dub> <49db6a18$1@forums-1-dub> <49db8805$1@forums-1-dub> <49db90c1$1@forums-1-dub> <49db9d6b$1@forums-1-dub> <49dbb1d5$1@forums-1-dub> <49dcb3a2$1@forums-1-dub>
X-Newsreader: Forte Agent 2.0/32.640
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: vip152.sybase.com
X-Original-NNTP-Posting-Host: vip152.sybase.com
Date: 10 Apr 2009 07:57:12 -0700
X-Trace: forums-1-dub 1239375432 10.22.241.152 (10 Apr 2009 07:57:12 -0700)
X-Original-Trace: 10 Apr 2009 07:57:12 -0700, vip152.sybase.com
Lines: 113
X-Authenticated-User: TeamSybase
Path: forums-1-dub!not-for-mail
Xref: forums-1-dub ianywhere.public.general:7508
Article PK: 5921

FYI... not everyone reads this particular newsgroup, so if you want
maximum exposure ( doesn't everyone? :) post your future questions in
sybase.public.sqlanywhere.general.

Breck

On 8 Apr 2009 07:24:34 -0700, "Bill Williams"

<billwilliams@qcsoftware.com> wrote:

>Thanks for the suggestion.
>
>"Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
>news:49dbb1d5$1@forums-1-dub...
>> Bill,
>>
>> Just a suggestion, I believe if you were to call
>> PreparedStatement.executeBatch() followed by
>> PreparedStatement.clearParameters(), you should be fine regardless of the
>> specific implementation of executeBatch().
>>
>> Karim
>> Bill Williams wrote:
>>> After I thought about it, the PreparedStatement is what I would use
>>> anyway because we use place holder parameters (duh).
>>>
>>> I did not realize the batch parameters are cleared after the executeBatch
>>> is called. I guess the problem is we are not guaranteed how other
>>> software such as Oracle, Microsoft and other vendors code their
>>> implementations of these methods. At the moment, I'm going to go ahead
>>> and just close the statement so I don't have to worry about it.
>>>
>>> Thanks
>>>
>>> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
>>> news:49db90c1$1@forums-1-dub...
>>>> Bill,
>>>>
>>>> When you create a Statement object, you do so without specifying any
>>>> SQL. When you use Statement.addBatch() you add SQL statements to the
>>>> batch. Executing Statement.executeBatch() sends the batched SQL
>>>> statements to the server, while executing Statement.clearBatch() deletes
>>>> all the batched SQL statements and sets the Statement object in an
>>>> initialized state with no SQL attached to it. The iAnywhere JDBC driver
>>>> does not support batches with Statement objects.
>>>>
>>>> Now, when you create a PreparedStatement object, you do so with a
>>>> specific SQL statement that may or may not have parameter markers.
>>>> Calling PreparedStatent.clearBatch() does not make sense since you
>>>> cannot have a PreparedStatement with no SQL statement attached. The main
>>>> reason for using a PreparedStatement is so that you do not have to
>>>> re-prepare the same SQL statement with the same set of parameter markers
>>>> every time you execute it. Calling PreparedStatement.addBatch() adds a
>>>> new row of parameters to the batch and calling
>>>> PreparedStatement.executeBatch() sends the batched parameter rows to the
>>>> server in one go and clears out all the batched parameters. If you now
>>>> want to batch up a new set of parameter rows you can do so without
>>>> re-preparing the PreparedStatment, BUT, if you want to use a completely
>>>> new SQL statement with a new set of parameter markers, then there is no
>>>> choice but to re-prepare the PreparedStatement. The iAnywhere JDBC
>>>> driver does support batches with PreparedStatement objects.
>>>>
>>>> Karim
>>>> Bill Williams wrote:
>>>>> If that's the way it has to be, then I guess I have to change my code
>>>>> but I'm sorry, this still does not make sense to me. To execute the
>>>>> batch, I'm using the executeBatch statement which is specified in
>>>>> Statement, not PreparedStatement. If I'm going to close and re-open a
>>>>> statement, I don't see any advantage to using a PreparedStatement.
>>>>>
>>>>> Anyway, I do appreciate the info.
>>>>>
>>>>> "Karim Khamis [Sybase iAnywhere]" <kkhamis@sybase.com> wrote in message
>>>>> news:49db6a18$1@forums-1-dub...
>>>>>> Bill Williams wrote:
>>>>>>> ASA 10.0.1 build 3835
>>>>>>>
>>>>>>> It appears the iAnywhere JDBC driver does support batch operations,
>>>>>>> yet since I am getting a not implemented exception, it must not
>>>>>>> support the clearBatch method. Why is this?
>>>>>>>
>>>>>>> In my code I am using a PreparedStatement for batch statements and
>>>>>>> always want to clear the batch statement after it has been executed
>>>>>>> in preparation to adding new batch updates to the same statement. Is
>>>>>>> this bad practice?
>>>>>>>
>>>>>>> Thanks
>>>>>>>
>>>>>>> Bill
>>>>>>>
>>>>>>>
>>>>>> Bill,
>>>>>>
>>>>>> The iAnywhere JDBC driver supports batch operations with
>>>>>> PreparedStatements. The driver does not support batch operations with
>>>>>> Statement objects. The Statement.clearBatch() method is used to clear
>>>>>> the list of SQL statements of a Statement batch operation. In the case
>>>>>> of PrearedStatements, there is only one SQL statement and executing
>>>>>> clearBatch is not well defined in this case. Note again that the
>>>>>> clarBatch method is specifically for Statements not
>>>>>> PreparedStatements. The best practice for prepared statements is to
>>>>>> issue a new call to Connection.prepareStatement thereby freeing up any
>>>>>> resources uses by the old prepared statement and old batch and
>>>>>> reinitializing the PreparedStatement object.
>>>>>>
>>>>>> Karim
>>>
>

--
Breck Carter http://sqlanywhere.blogspot.com/

RisingRoad SQL Anywhere and MobiLink Professional Services
breck.carter@risingroad.com