Welcome to dbFreaks.com!
FAQFAQ    SearchSearch      ProfileProfile    Private MessagesPrivate Messages   Log inLog in

JDBC running out of memory when calling a stored procedure..

 
   Database Help (Home) -> JDBC Driver RSS
Next:  urgent  
Author Message
James Bowkett

External


Since: Dec 16, 2008
Posts: 1



(Msg. 1) Posted: Mon Dec 15, 2008 12:30 pm
Post subject: JDBC running out of memory when calling a stored procedure using server side cursor and returning no data to client on sqlserver 2005
Archived from groups: microsoft>public>sqlserver>jdbcdriver (more info?)

Hi,

I am using Java 1.6.0 to call a stored procedure on SQLServer 2005. The
stored procedure iterates a server side cursor, and then inserts into a
table its status. However, I am getting a SQLException :
2008-12-15 16:26:26,624 ERROR [main] sqlRunner.SqlRunner (SqlRunner.java:66)
- com.microsoft.sqlserver.jdbc.SQLServerException: The system is out of
memory. Use server side cursors for large result sets:Java heap space.
Result set size:192,431,171. JVM total memory size:94,154,752.

When as far as I am aware, I _am_ using a server side cursor, so why is my
jdbc client receiving this error message?
Can someone explain what is going wrong?...Should I be passing a parameter
such as selectMethod=cursor or responseBuffering=adaptive to the driver?....
Even though the stored proc returns no data?

TIA,

-James


The rough outline of the code is:
jdbc call stored proc using connection.prepareCall
Stored proc opens a cursor to a large resultset
cursor is iterated
cursor completed
stored proc enters a status message in a table

The result of this is that the cursor is completed and the row is seen in
the status table, however on larger resultsets (and I have varied the result
set size) the out of memory error is seen.



Example stored proc:
===================
create proc sp_bare_bones_cursor_test
as

truncate table status

declare @cleaned_assignee varchar(350)

DECLARE test_CURSOR CURSOR FOR
SELECT correspondent_name from tb_rf_transactions
--3930271 7464412
--where patent_id < '7930271'

OPEN test_CURSOR
FETCH NEXT FROM test_CURSOR into @cleaned_assignee
WHILE @@FETCH_STATUS = 0
BEGIN

FETCH NEXT FROM test_CURSOR into @cleaned_assignee

END --WHILE @@FETCH_STATUS = 0

CLOSE test_CURSOR
DEALLOCATE test_CURSOR

insert into status values ('Finished cursor : ['+convert(varchar(200),
getdate())+']')



Example JDBC call:
=================

connection.prepareCall("sp_bare_bones_cursor_test");

url:http://www.ureader.com/gp/1148-1.aspx

 >> Stay informed about: JDBC running out of memory when calling a stored procedure.. 
Back to top
Login to vote
binvij

External


Since: Mar 18, 2008
Posts: 2



(Msg. 2) Posted: Tue Dec 16, 2008 5:37 am
Post subject: RE: JDBC running out of memory when calling a stored procedure using s [Login to view extended thread Info.]
Archived from groups: per prev. post (more info?)

Please use selectMethod=cursor. By default any resultset generated is
created in the client memory.

Please post back if this does not help .

--
Bindesh Vijayan
MSFT- SQL Developer Support

"James Bowkett" wrote:

> Hi,
>
> I am using Java 1.6.0 to call a stored procedure on SQLServer 2005. The
> stored procedure iterates a server side cursor, and then inserts into a
> table its status. However, I am getting a SQLException :
> 2008-12-15 16:26:26,624 ERROR [main] sqlRunner.SqlRunner (SqlRunner.java:66)
> - com.microsoft.sqlserver.jdbc.SQLServerException: The system is out of
> memory. Use server side cursors for large result sets:Java heap space.
> Result set size:192,431,171. JVM total memory size:94,154,752.
>
> When as far as I am aware, I _am_ using a server side cursor, so why is my
> jdbc client receiving this error message?
> Can someone explain what is going wrong?...Should I be passing a parameter
> such as selectMethod=cursor or responseBuffering=adaptive to the driver?....
> Even though the stored proc returns no data?
>
> TIA,
>
> -James
>
>
> The rough outline of the code is:
> jdbc call stored proc using connection.prepareCall
> Stored proc opens a cursor to a large resultset
> cursor is iterated
> cursor completed
> stored proc enters a status message in a table
>
> The result of this is that the cursor is completed and the row is seen in
> the status table, however on larger resultsets (and I have varied the result
> set size) the out of memory error is seen.
>
>
>
> Example stored proc:
> ===================
> create proc sp_bare_bones_cursor_test
> as
>
> truncate table status
>
> declare @cleaned_assignee varchar(350)
>
> DECLARE test_CURSOR CURSOR FOR
> SELECT correspondent_name from tb_rf_transactions
> --3930271 7464412
> --where patent_id < '7930271'
>
> OPEN test_CURSOR
> FETCH NEXT FROM test_CURSOR into @cleaned_assignee
> WHILE @@FETCH_STATUS = 0
> BEGIN
>
> FETCH NEXT FROM test_CURSOR into @cleaned_assignee
>
> END --WHILE @@FETCH_STATUS = 0
>
> CLOSE test_CURSOR
> DEALLOCATE test_CURSOR
>
> insert into status values ('Finished cursor : ['+convert(varchar(200),
> getdate())+']')
>
>
>
> Example JDBC call:
> =================
>
> connection.prepareCall("sp_bare_bones_cursor_test");
>
> url:http://www.ureader.com/gp/1148-1.aspx
>

 >> Stay informed about: JDBC running out of memory when calling a stored procedure.. 
Back to top
Login to vote
Display posts from previous:   
Related Topics:
How to genericaly search the entire db for any text string.. - How to genericaly search the entire db for any text string in any stored procedure, function, table definition, agent job, etc. Any one command or anyone have a stored proc that does this wide search?

JDBC 1.2 client against SQL 2005 JDBC 2.0 server? - We need to the server-side of this driver by running xa_install.sql. The client app running on WebSphere (on an app server) will be using version 1.2 of the JDBC driver. Is it safe to install the 2.0 version on the database server, or should we stick...

fetching stacked record sets in stored procedure - We are using stored procedures that execute multiple selects stacking the results in a single resultset. In ADO, you use the next record set method to move from one set to the next. Is there anyway to do this through JDBC? Its an urgent issue blocking....

New JDBC 1.2 driver runs slower than JDBC 1.1 driver-- exp.. - I have some test programs I run which do repeated simple SQL Select and SQL update statements. These test programs consistently take 5 to 10% longer to run with the new JDBC 1.2 driver than they do with the JDBC 1.1 driver. Is this expected? I..

JDBC Performance is no where near .NET performance (JDBC 1.. - I am finding that the adaptive buffering returns rows at the same rate as the server side cursor. It may improve client memory footprint on large resultsets but I cannot seem to get performance up to the level of a similar app written in .NET using..
   Database Help (Home) -> JDBC Driver All times are: Pacific Time (US & Canada)
Page 1 of 1

 
You can post new topics in this forum
You can reply to topics in this forum
You can edit your posts in this forum
You can delete your posts in this forum
You can vote in polls in this forum



[ Contact us | Terms of Service/Privacy Policy ]