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.

Memory Problem with a lot of statement executions in one connection

3 posts in JDBC Connect (product renamed to JConnect) Last posting was on 1997-06-23 12:45:28.0Z
Remo Schnidrig Posted on 1997-06-19 08:02:32.0Z
Message-ID: <33A8E798.D20@scsc.ethz.ch>
Date: Thu, 19 Jun 1997 10:02:32 +0200
From: Remo Schnidrig <schnidrig@scsc.ethz.ch>
Organization: Swiss Center for Scientific Computing
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4u)
MIME-Version: 1.0
Subject: Memory Problem with a lot of statement executions in one connection
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 77
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:659
Article PK: 252410

Hi all,

We plan to use a Java Client for constantly feeding in of financial data
in a Sybase database. Therefore I produced a class that maintains
one connection and produces for every insert a new statement.
The problem now is, that the connection class seems to constantly
allocate
new memory until the heap runs out of memory after about 20'000 calls to
the method storeTick().
Is it possible to give free the memory already used in the statement?
Is it necessary to close and reopen the connection to the server for
every
new insert of a row?

(stmt.close() doesn't work, because afterwards I get for the next
execution
of a statement an exception that says, that the cache has a Null
pointer.)


import java.io.*;
import java.sql.*;
import com.sybase.jdbc.Const;
import java.util.*;

import data.*;

public class ARTsybase {
static Connection con = null;
static Statement stmt = null;
static ResultSet rs;
static String user;
static String password;
static String server;


public ARTsybase(String server, String user, String password) {

this.server = server;
this.user = user;
this.password = password;

// open a connection to the Server
try {
Class.forName("com.sybase.jdbc.SybDriver");
}
catch (ClassNotFoundException e) {
System.out.println("Caught Class Not Found Exception");
System.out.println (e.getMessage ());
}
Properties props = new Properties();
props.put("user", user);
props.put("password", password);
props.put("STREAM_CACHE_SIZE", "50000");
props.put("NO_REPEAT_READ","1");
try {
con = DriverManager.getConnection(server, props);

printWarnings(con.getWarnings());
con.clearWarnings();
}
catch (SQLException e) {
System.out.println("Caught SQL Exception in 'ARTsybase'");
System.out.println (e.getMessage ());
System.out.println ("sqlstate = " + e.getSQLState());
e.printStackTrace();
}
}


public void storeTick(ARTForex tick) {

try {
stmt = con.createStatement();

stmt.executeUpdate("exec storeTick" + tick.item + " @bid = "+
tick.bid +
", @ask = "+ tick.ask +", @contr = "+ tick.contr +", @contr_time = "+
tick.contr_time +", @feed = "+ tick.feed +"\n");

stmt.clearWarnings();
}
catch (SQLException e) {
System.out.println("Caught SQL Exception in 'storeTick'");
System.out.println (e.getMessage ());
System.out.println ("sqlstate = " + e.getSQLState());
e.printStackTrace();
}
}

}


--
-----------------------------------------------------------------------
Remo Schnidrig
Swiss Center for Scientific Computing (SCSC)
Swiss Federal Institute of Technology
ETH-Zentrum, CLU B1
CH-8092 Zurich, Switzerland

Phone +41-1-632.5573
Fax +41-1-632.1104

email : schnidrig@scsc.ethz.ch ( MIME supported )
-----------------------------------------------------------------------


Lance Andersen Posted on 1997-06-20 20:43:21.0Z
Message-ID: <33AAEB69.B6@sybase.com>
Date: Fri, 20 Jun 1997 16:43:21 -0400
From: Lance Andersen <lancea@sybase.com>
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4m)
MIME-Version: 1.0
To: Remo Schnidrig <schnidrig@scsc.ethz.ch>
Subject: Re: Memory Problem with a lot of statement executions in one connection
References: <33A8E798.D20@scsc.ethz.ch>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 101
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:654
Article PK: 252405

Hi Remo,

I am not aware of any problems as you mention. Please try
the most current versionof the driver (new as of yesterday) and
if the error occurs, please provide a complete working example
along with the error and preferably the output from the jConnect
Debug.Debug method.

thanks

lance

Remo Schnidrig wrote:
>
> Hi all,
>
> We plan to use a Java Client for constantly feeding in of financial data
> in a Sybase database. Therefore I produced a class that maintains
> one connection and produces for every insert a new statement.
> The problem now is, that the connection class seems to constantly
> allocate
> new memory until the heap runs out of memory after about 20'000 calls to
> the method storeTick().
> Is it possible to give free the memory already used in the statement?
> Is it necessary to close and reopen the connection to the server for
> every
> new insert of a row?
>
> (stmt.close() doesn't work, because afterwards I get for the next
> execution
> of a statement an exception that says, that the cache has a Null
> pointer.)
>
> import java.io.*;
> import java.sql.*;
> import com.sybase.jdbc.Const;
> import java.util.*;
>
> import data.*;
>
> public class ARTsybase {
> static Connection con = null;
> static Statement stmt = null;
> static ResultSet rs;
> static String user;
> static String password;
> static String server;
>
> public ARTsybase(String server, String user, String password) {
>
> this.server = server;
> this.user = user;
> this.password = password;
>
> // open a connection to the Server
> try {
> Class.forName("com.sybase.jdbc.SybDriver");
> }
> catch (ClassNotFoundException e) {
> System.out.println("Caught Class Not Found Exception");
> System.out.println (e.getMessage ());
> }
> Properties props = new Properties();
> props.put("user", user);
> props.put("password", password);
> props.put("STREAM_CACHE_SIZE", "50000");
> props.put("NO_REPEAT_READ","1");
> try {
> con = DriverManager.getConnection(server, props);
>
> printWarnings(con.getWarnings());
> con.clearWarnings();
> }
> catch (SQLException e) {
> System.out.println("Caught SQL Exception in 'ARTsybase'");
> System.out.println (e.getMessage ());
> System.out.println ("sqlstate = " + e.getSQLState());
> e.printStackTrace();
> }
> }
>
> public void storeTick(ARTForex tick) {
>
> try {
> stmt = con.createStatement();
>
> stmt.executeUpdate("exec storeTick" + tick.item + " @bid = "+
> tick.bid +
> ", @ask = "+ tick.ask +", @contr = "+ tick.contr +", @contr_time = "+
> tick.contr_time +", @feed = "+ tick.feed +"\n");
>
> stmt.clearWarnings();
> }
> catch (SQLException e) {
> System.out.println("Caught SQL Exception in 'storeTick'");
> System.out.println (e.getMessage ());
> System.out.println ("sqlstate = " + e.getSQLState());
> e.printStackTrace();
> }
> }
>
> }
>
> --
> -----------------------------------------------------------------------
> Remo Schnidrig
> Swiss Center for Scientific Computing (SCSC)
> Swiss Federal Institute of Technology
> ETH-Zentrum, CLU B1
> CH-8092 Zurich, Switzerland
>
> Phone +41-1-632.5573
> Fax +41-1-632.1104
>
> email : schnidrig@scsc.ethz.ch ( MIME supported )
> -----------------------------------------------------------------------

--
===============================================================================
Lance J. Andersen Email: lancea@sybase.com
Sybase Technical Support Phone:(617) 564-6336
77 South Bedford Street Fax: (617) 564-6148
Burlington, MA 01803

The Dark Knight Returns!!! Let's Go Penguins!!!
===============================================================================


Remo Schnidrig Posted on 1997-06-23 12:45:28.0Z
Message-ID: <33AE6FE8.215C@scsc.ethz.ch>
Date: Mon, 23 Jun 1997 14:45:28 +0200
From: Remo Schnidrig <schnidrig@scsc.ethz.ch>
Organization: Swiss Center for Scientific Computing
X-Mailer: Mozilla 3.01Gold (X11; I; SunOS 5.5.1 sun4u)
MIME-Version: 1.0
Subject: Re: Memory Problem with a lot of statement executions in one connection
References: <33A8E798.D20@scsc.ethz.ch> <33AAEB69.B6@sybase.com>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Newsgroups: sybase.public.jdbcconnect
Lines: 29
Path: forums-1-dub!forums-master.sybase.com!forums.powersoft.com
Xref: forums-1-dub sybase.public.jdbcconnect:653
Article PK: 252406

Hi Lance,

> I am not aware of any problems as you mention. Please try
> the most current versionof the driver (new as of yesterday) and
> if the error occurs, please provide a complete working example
> along with the error and preferably the output from the jConnect
> Debug.Debug method.

We solved the problem. The problem was that we called the method
storeTick() from an RMI-method. We found out, that in the context
of a lot of consecutive calls of this RMI-method we get a concurrency
problem in the method storeTick() (I assume an inconsistency in the
cache of the Statement object).

We made now the method storeTick() to a s'ynchronized' method and
everything is (obviously) functioning without any problems.

Remo

--
-----------------------------------------------------------------------
Remo Schnidrig
Swiss Center for Scientific Computing (SCSC)
Swiss Federal Institute of Technology
ETH-Zentrum, CLU B1
CH-8092 Zurich, Switzerland

Phone +41-1-632.5573
Fax +41-1-632.1104

email : schnidrig@scsc.ethz.ch ( MIME supported )
-----------------------------------------------------------------------