I need to create a login with JSP and so, I need to use mysql-connector-java
.
I insert the file jar: mysql-connector-java-5.1.38-bin.jar
into WEB-INF/lib
and I use this code into the jsp file:
<%@
page import="java.sql.*"
%>
<%
String DRIVER = "com.mysql.jdbc.Driver";
String URL_mioDB = "jdbc:mysql://localhost:3306/ditta";
try
{
Class.forName(DRIVER);
}
catch (ClassNotFoundException e)
{
System.err.println("Driver not found" + e);
}
Connection connessione = null;
try
{
// apro la connesione verso il database.
connessione = DriverManager.getConnection(URL_mioDB,"root","");
}
catch (Exception e)
{
System.err.println("Error during connection with db : " + e);
}
String mail="",pass="",send="",query="";
try
{
mail=request.getParameter("email");
pass=request.getParameter("password");
send=request.getParameter("send");
out.println("<FORM name='F1' method='post' action='login.jsp'>");
out.println("Email: <INPUT type='text' name='email' value='' placeholder='mariorossi@gmail.com'><BR><BR>");
out.println("Password: <INPUT type='password' name='password' value=''><BR><BR>");
out.println("<INPUT type='submit' name='send' value='Invia'> <INPUT type='reset' name='reset' value='Reset'>");
out.println("</FORM>");
}
catch (Exception e)
{
System.err.println(e);
}
if(send!=null && mail!="" && pass!="")
{
query="SELECT * FROM dipendenti WHERE email="+ mail + " AND password=" + pass + "";
Statement statement = connessione.createStatement();
ResultSet resultSet = statement.executeQuery(query);
ResultSetMetaData rsmd = resultSet.getMetaData();
for(int i=0;i<=rsmd.getColumnCount();i++)
{
out.println(resultSet.getString(i));
}
}
%>
after that, When I click on the send button the page give me this error: