You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-user@db.apache.org by Amir Michail <am...@gmail.com> on 2007/01/04 23:18:27 UTC
strange out of memory exception
Hi,
I'm getting this exception:
java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040,
SQLERRMC: Failed to start database 'myDB', see the next exception for
details.::SQLSTATE: XJ001Java exception: 'Java heap space:
java.lang.OutOfMemoryError'.
Any ideas on how to debug this and/or increase the memory available?
There isn't much data in the db btw.
Amir
Re: strange out of memory exception
Posted by Stanley Bradbury <St...@gmail.com>.
Amir Michail wrote:
> Hi,
>
> I found this for tomcat 5.5;
>
> http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
>
>
> However, I still don't know what to do:
>
> * for derby db, do I need to put anything in server.xml and/or web.xml?
>
> * is there a howto like this specifically for derby db?
>
> * what is a reasonable way to debug this problem?
>
> Amir
>
There is information on setting up a datasource for Tomcat 5.5 in the
following article. Perhaps this will help:
http://db.apache.org/derby/integrate/DerbyTomcat5512JPetStor.html
Re: strange out of memory exception
Posted by Amir Michail <am...@gmail.com>.
Hi,
I found this for tomcat 5.5;
http://tomcat.apache.org/tomcat-5.5-doc/jndi-datasource-examples-howto.html
However, I still don't know what to do:
* for derby db, do I need to put anything in server.xml and/or web.xml?
* is there a howto like this specifically for derby db?
* what is a reasonable way to debug this problem?
Amir
Re: strange out of memory exception
Posted by Amir Michail <am...@gmail.com>.
On 1/5/07, Per Newgro <pe...@gmx.ch> wrote:
> Hey Amir,
>
> > Context envCtx=(Context)initCtx.lookup("java:comp/env");
> > DataSource ds = (DataSource)envCtx.lookup("jdbc/sampleDB"); // fails
> Is initCtx.lookup("java:comp/env/jdbc/sampleDB") working? Thats the way i do
> it normally.
>
No, that doesn't work. Same problem.
And putting this into the web.xml file doesn't help;
<dataSource type="JNDI">
<property name="DataSource" value= "java:comp/env/jdbc/sampleDB" />
</dataSource>
Perhaps there is a jar file that I need to copy into the lib directory
that is related to pooling?
Amir
> Cheers
> Per
>
Re: strange out of memory exception
Posted by Per Newgro <pe...@gmx.ch>.
Hey Amir,
> Context envCtx=(Context)initCtx.lookup("java:comp/env");
> DataSource ds = (DataSource)envCtx.lookup("jdbc/sampleDB"); // fails
Is initCtx.lookup("java:comp/env/jdbc/sampleDB") working? Thats the way i do
it normally.
Cheers
Per
Re: strange out of memory exception
Posted by Amir Michail <am...@gmail.com>.
On 1/4/07, Jose de Castro <jo...@voxeo.com> wrote:
> The best balance of performance and reliability will come from using a
> database connection pool.
>
> Here are a couple of good ones:
>
> DBCP - http://jakarta.apache.org/commons/dbcp/
> c3p0 - http://www.mchange.com/projects/c3p0/index.html
>
>
I tried using the tomcat support for this, but I get this exception:
javax.naming.NameNotFoundException: Name jdbc is not bound in this Context
Here's my context.xml file:
<?xml version="1.0" encoding="UTF-8"?>
<Context>
<Resource name="jdbc/sampleDB" auth="Container"
type="javax.sql.DataSource"
username="..." password="..."
driverClassName="org.apache.derby.jdbc.ClientDriver"
url="jdbc:derby://localhost:1527/myDB"
maxActive="8" />
</Context>
Here's the connection code:
try {
InitialContext initCtx = new InitialContext();
Context envCtx=(Context)initCtx.lookup("java:comp/env");
DataSource ds = (DataSource)envCtx.lookup("jdbc/sampleDB"); // fails
try {
connection = ds.getConnection();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (NamingException e) {
e.printStackTrace();
}
Amir
> Amir Michail wrote:
> > On 1/4/07, Amir Michail <am...@gmail.com> wrote:
> >> Hi,
> >>
> >> I'm getting this exception:
> >>
> >> java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040,
> >> SQLERRMC: Failed to start database 'myDB', see the next exception for
> >> details.::SQLSTATE: XJ001Java exception: 'Java heap space:
> >> java.lang.OutOfMemoryError'.
> >>
> >
> > Please ignore. I solved the problem.
> >
> > BTW, how long should a servlet hold on to a db connection? Should it
> > open a connection for each request? Or is it sufficient to just open a
> > connection once? Does it matter in terms of reliability of the db,
> > resource limits, etc.?
> >
> > Amir
> >
> >> Any ideas on how to debug this and/or increase the memory available?
> >>
> >> There isn't much data in the db btw.
> >>
> >> Amir
> >>
>
Re: strange out of memory exception
Posted by Jose de Castro <jo...@voxeo.com>.
The best balance of performance and reliability will come from using a
database connection pool.
Here are a couple of good ones:
DBCP - http://jakarta.apache.org/commons/dbcp/
c3p0 - http://www.mchange.com/projects/c3p0/index.html
Amir Michail wrote:
> On 1/4/07, Amir Michail <am...@gmail.com> wrote:
>> Hi,
>>
>> I'm getting this exception:
>>
>> java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040,
>> SQLERRMC: Failed to start database 'myDB', see the next exception for
>> details.::SQLSTATE: XJ001Java exception: 'Java heap space:
>> java.lang.OutOfMemoryError'.
>>
>
> Please ignore. I solved the problem.
>
> BTW, how long should a servlet hold on to a db connection? Should it
> open a connection for each request? Or is it sufficient to just open a
> connection once? Does it matter in terms of reliability of the db,
> resource limits, etc.?
>
> Amir
>
>> Any ideas on how to debug this and/or increase the memory available?
>>
>> There isn't much data in the db btw.
>>
>> Amir
>>
Re: strange out of memory exception
Posted by Amir Michail <am...@gmail.com>.
On 1/4/07, Amir Michail <am...@gmail.com> wrote:
> Hi,
>
> I'm getting this exception:
>
> java.sql.SQLException: DERBY SQL error: SQLCODE: -1, SQLSTATE: XJ040,
> SQLERRMC: Failed to start database 'myDB', see the next exception for
> details.::SQLSTATE: XJ001Java exception: 'Java heap space:
> java.lang.OutOfMemoryError'.
>
Please ignore. I solved the problem.
BTW, how long should a servlet hold on to a db connection? Should it
open a connection for each request? Or is it sufficient to just open a
connection once? Does it matter in terms of reliability of the db,
resource limits, etc.?
Amir
> Any ideas on how to debug this and/or increase the memory available?
>
> There isn't much data in the db btw.
>
> Amir
>