You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Lorenzo Sicilia <ar...@kemen.it> on 2004/11/15 13:22:15 UTC

sql Connection.close() has already been called

Hi to all,

I have a stange error in some index.jsp in two web site where I use sql tag.
error:
java.sql.SQLException: Connection.close() has already been called. Invalid
operation in this state

It's strange because I use only one tag sql in the page and the problem 
it's random.

my snippets:

<c:set var="idcom" value="${param.id}" />
<c:set var="init" value="${param.init}" />
<c:set var="final" value="${final}" />


<c:if test="${empty param.init}" >
	<c:set var="init" value="a" />
	<c:set var="final" value="b" />
</c:if>

<sql:query var="comuni">
	SELECT IDLocation,location
	FROM location
	WHERE (location >=  ?
		AND location <  ?
		OR location	LIKE ?)
		AND visible = 1
	ORDER BY location	
	<sql:param value="${init}" />
	<sql:param value="${final}"/>
	<sql:param value="${final}"/>
</sql:query>

any idea?

regards Lorenzo

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql Connection.close() has already been called

Posted by Lorenzo Sicilia <ar...@kemen.it>.
Glenn Nielsen wrote:
> MySQL will by default close a db connection after it has been idle
> for 8 hours. You need to add the following to your jdbc connect url
> "?autoReconnect=true" to tell the MySQL JDBC driver to automatically
> reconnect to the db.
> 
> Your url would be:
> 
> <url>jdbc:mysql://localhost:3306/mkterritoriale?autoReconnect=true</url>
> 
> This might solve your problem.

mmm... very interesting but why only one page "crash"?
The other pages work fine.
Anyway I try it.

many thanks.

regards Lorenzo

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql Connection.close() has already been called

Posted by Glenn Nielsen <gl...@mail.more.net>.
MySQL will by default close a db connection after it has been idle
for 8 hours. You need to add the following to your jdbc connect url
"?autoReconnect=true" to tell the MySQL JDBC driver to automatically
reconnect to the db.

Your url would be:

<url>jdbc:mysql://localhost:3306/mkterritoriale?autoReconnect=true</url>

This might solve your problem.

Regards,

Glenn

On Mon, Nov 15, 2004 at 05:08:51PM +0100, Lorenzo Sicilia wrote:
> Kris Schneider wrote:
> >Do you have a context init param in web.xml for
> >"javax.servlet.jsp.jstl.sql.dataSource"? If so, are you using a JNDI 
> >relative
> >path or a JDBC parameters string?
> Yes, I have. In my web.xml
> <!-- JSTL DATASOURCE -->
> <context-param>
>       <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
>       <param-value>mkterritoriale</param-value>
> </context-param>
> 
> in my jrun-resource.xml
> in my datasource:
> <data-source>
> <dbname>mkterritoriale</dbname>
> <driver>org.gjt.mm.mysql.Driver</driver>
> <url>jdbc:mysql://localhost:3306/mkterritoriale</url>
> <username>mkterritoriale</username>
> <password>024D558B4C511144AACF41A214868DAB</password>
> <encrypted>true</encrypted>
> <encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
> <native-results>true</native-results>
> <remove-on-exceptions>true</remove-on-exceptions>
> <pool-statements>true</pool-statements>
> <initial-connections>1</initial-connections>
> <connection-timeout>1200</connection-timeout>
> <transaction-timeout>20</transaction-timeout>
> <cache-enabled>false</cache-enabled>
> <cache-size>5</cache-size>
> <cache-refresh-interval>30</cache-refresh-interval>
> <jndi-name>mkterritoriale</jndi-name>
> <poolname>Pool</poolname>
> <minimum-size>0</minimum-size>
> <maximum-size>2147483647</maximum-size>
> <user-timeout>20</user-timeout>
> <skimmer-frequency>420</skimmer-frequency>
> <shrink-by>5</shrink-by>
> <maximum-soft>true</maximum-soft>
> <debugging>false</debugging>
> <disable-pooling>false</disable-pooling>
> <description/>
> </data-source>
> 
> 
>  Which version of the Standard taglib (JSTL)
> >are you using (1.0 or 1.1)?
> 1.0.6
> 
> >As an aside, attempting to close a connection that is already closed is a 
> >no-op,
> >it should not generate an error. The same holds true for a statement. What 
> >JDBC
> >driver are you using?
> mysql-connector-java-3.0.15-ga-bin.jar
> 
> thanks in advace.
> 
> regards Lorenzo
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
----------------------------------------------------------------------
Glenn Nielsen             glenn@more.net | /* Spelin donut madder    |
MOREnet System Programming               |  * if iz ina coment.      |
Missouri Research and Education Network  |  */                       |
----------------------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql Connection.close() has already been called

Posted by Lorenzo Sicilia <ar...@kemen.it>.
Kris Schneider wrote:
> Do you have a context init param in web.xml for
> "javax.servlet.jsp.jstl.sql.dataSource"? If so, are you using a JNDI relative
> path or a JDBC parameters string?
Yes, I have. In my web.xml
<!-- JSTL DATASOURCE -->
<context-param>
       <param-name>javax.servlet.jsp.jstl.sql.dataSource</param-name>
       <param-value>mkterritoriale</param-value>
</context-param>

in my jrun-resource.xml
in my datasource:
<data-source>
<dbname>mkterritoriale</dbname>
<driver>org.gjt.mm.mysql.Driver</driver>
<url>jdbc:mysql://localhost:3306/mkterritoriale</url>
<username>mkterritoriale</username>
<password>024D558B4C511144AACF41A214868DAB</password>
<encrypted>true</encrypted>
<encryption-class>jrun.security.JRunCrypterForTwofish</encryption-class>
<native-results>true</native-results>
<remove-on-exceptions>true</remove-on-exceptions>
<pool-statements>true</pool-statements>
<initial-connections>1</initial-connections>
<connection-timeout>1200</connection-timeout>
<transaction-timeout>20</transaction-timeout>
<cache-enabled>false</cache-enabled>
<cache-size>5</cache-size>
<cache-refresh-interval>30</cache-refresh-interval>
<jndi-name>mkterritoriale</jndi-name>
<poolname>Pool</poolname>
<minimum-size>0</minimum-size>
<maximum-size>2147483647</maximum-size>
<user-timeout>20</user-timeout>
<skimmer-frequency>420</skimmer-frequency>
<shrink-by>5</shrink-by>
<maximum-soft>true</maximum-soft>
<debugging>false</debugging>
<disable-pooling>false</disable-pooling>
<description/>
</data-source>


  Which version of the Standard taglib (JSTL)
> are you using (1.0 or 1.1)?
1.0.6

> As an aside, attempting to close a connection that is already closed is a no-op,
> it should not generate an error. The same holds true for a statement. What JDBC
> driver are you using?
mysql-connector-java-3.0.15-ga-bin.jar

thanks in advace.

regards Lorenzo


---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql Connection.close() has already been called

Posted by Kris Schneider <kr...@dotech.com>.
Do you have a context init param in web.xml for
"javax.servlet.jsp.jstl.sql.dataSource"? If so, are you using a JNDI relative
path or a JDBC parameters string? Which version of the Standard taglib (JSTL)
are you using (1.0 or 1.1)?

As an aside, attempting to close a connection that is already closed is a no-op,
it should not generate an error. The same holds true for a statement. What JDBC
driver are you using?

Quoting Lorenzo Sicilia <ar...@kemen.it>:

> Don Albertson wrote:
> > Random as in it happens sometimes the first time or random as in it
> happens
> > sometimes after sitting inactive long enough for some timeout value to 
> > close
> > the connection?
> 
> Random as in it happens sometimes.
> When it happens I need restart the application server (jrun4).
> The page is "blocked". I can't refresh it. I get always the error.
> 
> regards Lorenzo

-- 
Kris Schneider <ma...@dotech.com>
D.O.Tech       <http://www.dotech.com/>

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql Connection.close() has already been called

Posted by Lorenzo Sicilia <ar...@kemen.it>.
Don Albertson wrote:
> Random as in it happens sometimes the first time or random as in it happens
> sometimes after sitting inactive long enough for some timeout value to 
> close
> the connection?

Random as in it happens sometimes.
When it happens I need restart the application server (jrun4).
The page is "blocked". I can't refresh it. I get always the error.

regards Lorenzo

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org


Re: sql Connection.close() has already been called

Posted by Don Albertson <da...@pennswoods.net>.

Lorenzo Sicilia wrote:
> Hi to all,
> 
> I have a stange error in some index.jsp in two web site where I use sql 
> tag.
> error:
> java.sql.SQLException: Connection.close() has already been called. Invalid
> operation in this state
> 
> It's strange because I use only one tag sql in the page and the problem 
> it's random.


Random as in it happens sometimes the first time or random as in it happens
sometimes after sitting inactive long enough for some timeout value to close
the connection?





> 
> my snippets:
> 
> <c:set var="idcom" value="${param.id}" />
> <c:set var="init" value="${param.init}" />
> <c:set var="final" value="${final}" />
> 
> 
> <c:if test="${empty param.init}" >
>     <c:set var="init" value="a" />
>     <c:set var="final" value="b" />
> </c:if>
> 
> <sql:query var="comuni">
>     SELECT IDLocation,location
>     FROM location
>     WHERE (location >=  ?
>         AND location <  ?
>         OR location    LIKE ?)
>         AND visible = 1
>     ORDER BY location   
>     <sql:param value="${init}" />
>     <sql:param value="${final}"/>
>     <sql:param value="${final}"/>
> </sql:query>
> 
> any idea?
> 
> regards Lorenzo
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: taglibs-user-help@jakarta.apache.org
> 
> 


-- 
"Our lives begin to end the day we become silent about things that matter."
Martin Luther King, Jr.

---------------------------------------------------------------------
To unsubscribe, e-mail: taglibs-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: taglibs-user-help@jakarta.apache.org