Hi !!
-----Original Message-----
From: Claumir Claudino dos Santos <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
Date: Wednesday, April 07, 1999 4:11 AM
Subject: Servlet + DB = crash!
>Hello,
>
>I'm writing a simple servlet for get the time of my database. The code
>of my servlet is below. After a few simultaneous requests the servlet
>not more respond
>(I'm using the JRun 2.3 servlet engine on NT and the database is MS
>Access).
>Any help is welcome.
>
>Thanks in advance!
>
>Claumir
>____________________
>
>import java.io.*;
>import java.util.Date;
>import javax.servlet.*;
>import javax.servlet.http.*;
>import java.sql.*;
>
>public class DateServlet extends HttpServlet
>{
> Connection con;
> Statement stmt;
> String today ="";
>
> public void service(HttpServletRequest req, HttpServletResponse res)
>throws IOException
> {
> res.setContentType("text/html");
> ServletOutputStream out = res.getOutputStream();
>
> connectDataBase();
>
> out.println("<html>");
> out.println("<head>");
> out.println("<Title>");
> out.println("<Teste de Servlets>");
> out.println("</title>");
> out.println("</head>");
> out.println("<body bgcolor=\"lime\">");
> out.println("<h1>"+ today +"</h1>");
> out.println("</body>");
> out.println("</html>");
> }
>
> public synchronized void connectDataBase()
> {
> try
> {
> Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
> con = DriverManager.getConnection("jdbc:odbc:ecap","","");
> stmt = con.createStatement();
>
> ResultSet rs = stmt.executeQuery("select date() as today from
>
>tab_imoveis");
> ResultSetMetaData rsmd = rs.getMetaData();
the rsmd is not used abow. Maybe in the future ??
>
> while (rs.next())
> today = rs.getString(1);
>
here you should put
rs.close();
stmt.close();
> }
> catch(Exception e)
> {
> System.out.println("Exception Conectando no Banco de dados:
>"+e);
> }
> }
>}
>--
>_____________________________
>
>Claumir Claudino dos Santos
>[EMAIL PROTECTED]
>
>Dynamix Software
>http://www.dynamix.com.br
>+55 (047) 323-3598, ramal 29
>Blumenau, SC - Brasil
>_____________________________
>
>___________________________________________________________________________
>To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
>of the message "signoff SERVLET-INTEREST".
>
>Archives: http://archives.java.sun.com/archives/servlet-interest.html
>Resources: http://java.sun.com/products/servlet/external-resources.html
>LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html