You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Claus Jul Larsen <cj...@enovasion.dk> on 2001/08/21 08:58:57 UTC

JSP and MySQL

Hi!

I've a problem with JSP and MySQL.

I use the org.gjt.mm.mysql.Driver class (from
dk.enovasion.db.MySqlDbConnect) and use the jsp file:

---- C U T ----

<%@ page language="java" contentType="text/html" %>
<%@ page import="java.sql.*" %>
<%@ page import="dk.enovasion.db.*" %>

<HTML>
<HEAD>
<TITLE>A JSP update</TITLE>
</HEAD>
<BODY BGCOLOR="#EEEEEE">
<CENTER><H3>JSP UPDATE</H3></CENTER>

<%
	MySqlDbConnect db = new MySqlDbConnect();
	Connection con =
db.getCon("zx81.enovasion.dk",0,"vaccination_dyn2","vaccination","84ep_ssi")
;
	Statement Stmt = db.getStatement(con); 
	ResultSet RS = Stmt.executeQuery("SELECT id,sygdom from tblData5");
	while (RS.next()) {
%>
			<%= RS.getString(1) %>
			<br>
			<%= RS.getString(2) %>
<%		}

		// Clean up after ourselves
        RS.close();
		Stmt.close();
		db.closeCon(con);
%>

<BODY>
</HTML>

--- C U T E N D ---

The problem is the db.closeCon(con) because if I run the Jsp-file first time
it's working well. Next time comes a NullPointerException. Why? If I remove
the db.closeCon(con) line it's working fine but other databases cannot
access because the connection is possibly open?!

I've tested the progeam in an ordinary class i a shell and it's working
fine.

Maybe it's problem with the cache?






> Med venlig hilsen
> 
>   Claus Jul Larsen
>   |  System Developer
>   |  cjlarsen@enovasion.dk
>   |  Direkte teksttelefon: 7731 2010, ring først til 
>   |  teksttelefoncenteret på 7011 4411 og bed om        
>   |  nummeret.
> 	
>   e|novasion a·s
>   |  store kongensgade 23a
>   |  DK - 1264 københavn k
>   |  tlf: +45 7731 1940  
>   |  fax: +45 7731 1950
>   |  www.enovasion.dk
> 
>