If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Trouble with MySQL+TOMCAT Resultset

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-07-03, 16:45
Toum Toum is offline
Registered User
 
Join Date: Nov 2003
Posts: 4
Unhappy Trouble with MySQL+TOMCAT Resultset

I'm programming applets & servlets on Tomcat and MySQL with my desktop (PIII500 - Win2000 - 512Mo).

- jakarta-tomcat-4.1.27-LE-jdk14
- mysql-4.0.14b
- j2sdk1.4.2
- mysql-connector-java-3.0.9-stable
- Tomcat DBCP (collections-2.1 dbcp-1.0 pool-1.0.1)

But ! I can not have stable behaviour with ResultSet :

- Sometimes all records are returned. Fine !!!
- Sometimes, 0 (Zero) record is returned. Too bad !
- Sometimes, some (but not all) records are returned. Bad !

And, When all records are not returned, one of the two following exception types is raised :

java.sql.SQLException: Operation not allowed after ResultSet closed
at com.mysql.jdbc.ResultSet.checkClosed(ResultSet.jav a:3601)
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.jav a:3614)
....

OR

java.lang.NullPointerException
at com.mysql.jdbc.ResultSet.checkRowPos(ResultSet.jav a:3625)
at com.mysql.jdbc.ResultSet.getString(ResultSet.java: 1772)
at org.apache.commons.dbcp.DelegatingResultSet.getStr ing(DelegatingResultSet.java:137)
....

What my application does :

- Inserting rows in a table (strings, dates, integers).
- And the, selecting table in a Resultset for gettind data
- I use ResultSet.getString() for getting all fields.

Database Pooling configuration in server.xml file :

<parameter>
<name>maxActive</name>
<value>10</value>
</parameter>

<parameter>
<name>maxIdle</name>
<value>0</value>
</parameter>

<parameter>
<name>maxWait</name>
<value>15000</value>
</parameter>

What I DO NOT suspect :

- Having not closed connection, statement or cursor.
- Doing some computation with null variables.

Thanks in advance for your help.

Toum.
Reply With Quote
  #2 (permalink)  
Old 11-09-03, 06:49
omiossec omiossec is offline
Registered User
 
Join Date: Jan 2003
Location: Paris, France
Posts: 320
I think that there is some thing really wrong in your code (for example you do not test your querry result, if the connection is still avaible ...)
__________________
Olivier Miossec
--
http://www.lasso-developpeur.net/
--
Reply With Quote
  #3 (permalink)  
Old 11-09-03, 14:14
Toum Toum is offline
Registered User
 
Join Date: Nov 2003
Posts: 4
Thanks Olivier for your reply.

Do you mean I have to put the code inside the "try" in a loop and let it run until I get a valid Resultset ? Do you know how I could make sure my Resultset is valid. I could test if (t_rs != null) of course. What if t_rs is not null but is valid only for the first records (obtained by t_rs.next()) ?

In my case, It seems that the t_rs is not null, but something wrong happenned when the next is called.

protected void executeSelect(String str)
{
try
{
if (ds != null)
{
t_conn = ds.getConnection();
if (t_conn != null)
{
t_stm =t_conn.prepareStatement(str);
if (t_stm != null)
{
t_rs = t_stm.executeQuery();
}
}
}
}
catch (Exception e)
{
}
}
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On