[opencms-dev] nested SQL Exception if connection pool

Christoph P. Kukulies kuku at physik.rwth-aachen.de
Fri Feb 29 17:31:13 CET 2008


On Fri, Feb 29, 2008 at 04:46:00PM +0100, Jordi Mart? wrote:
> Do you free statements and close connections?
> 
> try {
> 	Connection c=getSqlManager()......;
> 	ResultSet rs=c....
> 	}
> catch (Exception e) {
> 	e.printStackTrace();
> 	}
> finally {
> 	rs.close();
> 	c.close();
> 	}

I'm getting 
An error occurred at line: 88 in the jsp file:
/WEB-INF/jsp/offline/system/modules/org.yaml.frontend/templates/yamlmain.jsp
rs cannot be resolved
85: e.printStackTrace();
86: }
87: finally {
88: rs.close();
89: c.close();
90: }
91: %>

An error occurred at line: 89 in the jsp file:
/WEB-INF/jsp/offline/system/modules/org.yaml.frontend/templates/yamlmain.jsp
c cannot be resolved
86: }
87: finally {
88: rs.close();
89: c.close();
90: }
91: %>
92: </div>


Here is my template code:

<%@page import="org.opencms.jsp.*,org.opencms.file.*,java.util.*,java.sql.*" %>
<%@ taglib prefix="cms" uri="http://www.opencms.org/taglib/cms" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
       
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<cms:template element="head" >
<cms:include file="../elements/yamlhead" element="head"/>
</cms:template>
      <div id="main">
        <div id="col1">
          <div id="col1_content" class="clearfix">
            <!-- add your content here -->
<%
         CmsJspActionElement jsp = new CmsJspActionElement(pageContext,
request,response);

         String konto=request.getParameter("konto");
         String tmp,item,desc,id;
          
         try { 
             java.sql.Connection c =
            org.opencms.main.OpenCms.getSqlManager().getConnection("application");
            java.sql.Statement st = c.createStatement();
           java.sql.ResultSet rs = st.executeQuery("select id,name from
konten");
            java.sql.ResultSetMetaData md = rs.getMetaData();
            out.println("\n<ul>");
            while(rs.next()) {
                out.println("\n<li>");
                for(int i=1; i<= md.getColumnCount(); i++) {
                  item=rs.getString(i);
                  tmp = "<a
href=\"/opencms/opencms/sites/kuku/index.html?konto=" +item + "\" >"+
item + "</a>";

                  if(tmp == null)
                      tmp=" ";
                  out.println(  tmp );
                }
            out.println("</li>");
           }
            out.println("</ul>");

%>

          </div>
        </div>
        <div id="col2">
          <div id="col2_content" class="clearfix">
            <!-- add your content here -->



          </div>
        </div>
        <div id="col3">
          <div id="col3_content" class="clearfix">
            <!-- add your content here -->
<%
      
      if(( id=request.getParameter("konto"))!=null){
           rs = st.executeQuery("select * from buchung where
konto="+id);
          ;
          out.println("\n<ul>");
          md = rs.getMetaData();
          while(rs.next()) {
                out.println("\n<li>");
                for(int i=1; i<= md.getColumnCount(); i++) {
                  item=rs.getString(i);
                  
                  tmp =  item ;
               if(tmp == null)
                      tmp=" ";
                  out.println(  tmp );
                }
            out.println("</li>");
          }
         
          out.println("</ul>");
        } else { out.println("<h2>Set empty</h2>"); }
        } catch (Exception e) {
               e.printStackTrace();
         }
finally  {
      rs.close();
      c.close();
}
%>
          </div>
          <!-- IE Column Clearing -->
          <div id="ie_clearing">   </div>
        </div>
      </div>
    </div>
  </div>
</body>
</html>

> 
>    
>  
> JORDI MARTÍ 
> Email: jmarti at theinit.com
> Tlfno: 944.01.50.40 - Fax: 944.153.424
> Móvil: 605.41.82.93
> Skype ID: jmarti.theinit
>  
>  
>  
>  
>  
>  
--
Chris Christoph P. U. Kukulies kukulies (at) rwth-aachen.de



More information about the opencms-dev mailing list