Nuovo tipo di errore
ho sbagliato la connessione al database?
GRAVE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at com.javatpoint.mypack.UserDao.register(UserDao.java:66)
at org.apache.jsp.register_jsp._jspService(register_jsp.java:142)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
qui il codice della connessione al db e registrazione utente
public static int register(User user)throws HibernateException{
int i=0;
SessionFactory factory=null;
Session session = factory.openSession();
Transaction tx = null;
Integer employeeID = null;
try{
tx = session.beginTransaction();
User employee = new User();//(fname, lname, salary);
employeeID = (Integer)session.save(employee);
tx.commit();
}catch (HibernateException e) {
if (tx!=null) tx.rollback();
e.printStackTrace();
}finally {
session.close();
}
return employeeID;
}