Hi,
I am trying to write a .jsp. I work with a database pool connection. I read the
following in a faq (http://www.esperanto.org.nz/jsp/jspfaq.html) to instantiate the
DBConnectionManager (s. below). I am using the JavaWebServer2.0 and I put the
DBConnectionManager.class and the DBConnectionManager$DBConnectionPool.class in the
classes directory. So it must be loaded by the system class loader. What ist wrong?
Here is the script:
<%@ page isThreadSafe="true" import="java.sql.*" %>
<script RUNAT="SERVER">
DBConnectionManager connMgr = DBConnectionManager.getInstance();
</script>
<%!
String Password, Origin = "home.html";
%>
<%
if (request.getParameter("Emp_ID") != "" && request.getParameter("Emp_ID") != null) {
// DBConnectionManager connMgr = DBConnectionManager.getInstance();
Connection con = connMgr.getConnection("access");
if (con == null){
out.println ( "<P><PRE>" );
out.println("Can't get connection");
out.println ( "</PRE><P>" );
return;
}
try {
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select Emp_Password where Emp_ID = "
+ request.getParameter("Emp_ID"));
stmt.close();
rs.next();
Password = rs.getString("Emp_Password");
}
catch (SQLException ex) {
out.println ( "<P><PRE>" );
while (ex != null) {
out.println("Message: " + ex.getMessage ());
out.println("SQLState: " + ex.getSQLState ());
out.println("ErrorCode: " + ex.getErrorCode ());
ex = ex.getNextException();
out.println("");
}
out.println ( "</PRE><P>" );
}
if (Password != null &&
Password.equalsIgnoreCase(request.getParameter("Emp_Passwort"))) {
session.putValue("Emp_ID", request.getParameter("Emp_ID"));
if (request.getParameter("Origin") != null) Origin =
request.getParameter("Origin");
response.sendRedirect(response.encodeRedirectUrl(request.getParameter("Origin")));
}
connMgr.freeConnection("access",con);
}
%>
And here the error I got:
Error during compilation :
E:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_login.java:80: Undefined variable
or class name: connMgr
Connection con = connMgr.getConnection("access");
^
E:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_login.java:111: Undefined variable
or class name: connMgr
connMgr.freeConnection("access",con);
^
Note: E:\JavaWebServer2.0\tmpdir\default\pagecompile\jsp\_login.java uses or overrides
a deprecated API. Recompile with "-deprecation" for details.
2 errors, 1 warning
Thanks a lot for the help.
Christian Ribeaud
Predict AG
===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:
http://java.sun.com/products/jsp/faq.html
http://www.esperanto.org.nz/jsp/jspfaq.html
http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets