I have a web application that has been working for ages now.. suddenly I get this message when I am trying to login:
javax.servlet.ServletException: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
As I said before it has been working for over 3 years now… but the people who does the hosting for me have not been able to do anything… I have my driver on the WEB-INF folder and everything… can the folder’s permissions cause this problem? I have them set as 0744…any idea?
This is the screen shot of the WEB-INF folder:
I managed to login to the web application but the login jsp file is not working because the connection is not happening… here is the code:
<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java" session="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Accesando a Vecinet</title>
</head>
<body>
<%
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/etoolsco_VecinetSM?user=etoolsco&password=xxxx");
ResultSet rsdoLogin = null;
PreparedStatement psdoLogin=null;
String uname=request.getParameter("j_username");
String upass=request.getParameter("j_password");
String message="User login successfully ";
%>
<% try
{
String sqlOption="SELECT * FROM logins where"
+" usuario=? and clave=?";
psdoLogin=conn.prepareStatement(sqlOption);
psdoLogin.setString(1,uname);
psdoLogin.setString(2,upass);
rsdoLogin=psdoLogin.executeQuery();
if(rsdoLogin.next())
{
session.setAttribute("usuario",rsdoLogin.getString("usuario"));
session.setAttribute("clave",rsdoLogin.getString("clave"));
session.setAttribute("nombre",rsdoLogin.getString("nombre"));
session.setAttribute("apellido",rsdoLogin.getString("apellido"));
session.setAttribute("role",rsdoLogin.getString("role"));
session.setMaxInactiveInterval(7200);
response.sendRedirect("Vecinetspace.jsp?error="+message);
}
else
{
response.sendRedirect("error.jsp?error=");
}
}
catch(Exception e)
{
e.printStackTrace();
}
try{
if(psdoLogin!=null){
psdoLogin.close();
}
if(rsdoLogin!=null){
rsdoLogin.close();
}
if(conn!=null){
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</body>
</html>
This is the same login.jsp code for the application that is working:
<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@ page language="java" import="java.sql.*" errorPage="" %>
<%@ page language="java" session="true" %>
<html>
<head><title>Login to CRD</title>
</head>
<body>
<%
Connection conn = null;
Class.forName("com.mysql.jdbc.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:mysql://localhost/etoolsco_labsmb?user=etoolsco&password=xxx");
ResultSet rsdoLogin = null;
PreparedStatement psdoLogin=null;
String uname=request.getParameter("j_username");
String upass=request.getParameter("j_password");
String message="User login successfully ";
%>
<% try
{
String sqlOption="SELECT * FROM logins where"
+" usuario=? and clave=?";
psdoLogin=conn.prepareStatement(sqlOption);
psdoLogin.setString(1,uname);
psdoLogin.setString(2,upass);
rsdoLogin=psdoLogin.executeQuery();
if(rsdoLogin.next())
{
session.setAttribute("usuario",rsdoLogin.getString("usuario"));
session.setAttribute("clave",rsdoLogin.getString("clave"));
session.setAttribute("nombre",rsdoLogin.getString("nombre"));
session.setAttribute("apellido",rsdoLogin.getString("apellido"));
session.setAttribute("role",rsdoLogin.getString("role"));
session.setMaxInactiveInterval(600);
response.sendRedirect("BMRspace.jsp?error="+message);
}
else
{
response.sendRedirect("error.jsp?error=");
}
}
catch(Exception e)
{
e.printStackTrace();
}
try{
if(psdoLogin!=null){
psdoLogin.close();
}
if(rsdoLogin!=null){
rsdoLogin.close();
}
if(conn!=null){
conn.close();
}
}
catch(Exception e)
{
e.printStackTrace();
}
%>
</body>
</html>