I have written a very simple
servlet bt as soon I execute it, gives me an exception
>>java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not implemented
at line >>>>>>>>>>>>> pstmt.setLong(1,id);
the comp code is....
package com.employee;
import java.sql.*;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.employee.*;
public class AddEmployeeServlet extends HttpServlet{
Connection conn;
private
String name;
private String emailID;
private String emailAccount;
private String password;
private String dateCreated;
private String joinedDate;
private String resignedDate;
private String currentLocation;
private String lastLocation;
private String designation;
private boolean isResigned;
public void doGet(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
doPost(request,response);
}
public void doPost(HttpServletRequest request,HttpServletResponse response) throws ServletException,IOException{
String strJDate=request.getParameter("mmJoined")+"/"+request.getParameter("ddJoined")+"/"+request.getParameter("yyJoined");
String strRDate=request.getParameter("mmResigned")+"/"+request.getParameter("ddResigned")+"/"+request.getParameter("yyResigned");;
String strCDate=request.getParameter("mmCreated")+"/"+request.getParameter("ddCreated")+"/"+request.getParameter("yyCreated");;
// Calendar calendar = new GregorianCalendar(request.getParameter("joinDate"));
// Date dtJoin =new Date(request.getParameter("joinDate"));
// Date dtResignd =new Date(request.getParameter("resignedDare"));
// Date dtCreated =new Date(request.getParameter("deteCreated"));
PreparedStatement pstmt =null;
try{
HttpSession session=request.getSession();
System.out.println("Forwarding req>>>session:"+session);
if (session==null){response.sendRedirect("http://vijay:8080/emailuser/index.jsp");}
System.out.println("Forwarding req>>> after");
BoundConnection boundConnection=(BoundConnection)session.getValue("BOUNDCONNECTION");
conn=boundConnection.getConnection();
if (conn==null){
System.out.println("conn value>>>>:"+conn);
response.sendRedirect("index.jsp");
System.out.println("SOULD NOT DISPLAY:"+conn);
}
System.out.println("Hello");
name=request.getParameter("name");
emailID=request.getParameter("emailID");
emailAccount=request.getParameter("emailAccount");
password=request.getParameter("password");
// dateCreated=request.getParameter("joinDate");
// joinedDate=request.getParameter("resignedDate");
// resignedDate=request.getParameter("deteCreated");
currentLocation=request.getParameter("currentLocation");
lastLocation=request.getParameter("lastLocation");
designation=request.getParameter("designation");
if(request.getParameter("isResigned").equalsIgnoreCase("yes"))
isResigned=true;
else
isResigned=false;
long id=GetID.getID("employee","empid",conn)+1;
System.out.println("ID:"+id);
pstmt=this.conn.prepareStatement("INSERT INTO employee (empid,name,email,emailaccount,password,datejoined,dateresigned,datecreated,lastlocation,currentlocation,designation,resigned) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)");
System.out.println("1100");
pstmt.setLong(1,id); // error line if I commented it then code is executed smoothly
System.out.println("100");
pstmt.setString(1,name);
System.out.println("101");
pstmt.setString(2,emailID);
System.out.println("102");
pstmt.setString(3,emailAccount);
System.out.println("103");
pstmt.setString(4,password);
System.out.println("104");
pstmt.setString(5,strJDate);
pstmt.setString(6,strRDate);
pstmt.setString (7,strCDate);
System.out.println("105");
System.out.println("106");
System.out.println("107");
pstmt.setString(8,currentLocation);
System.out.println("108");
pstmt.setString(9,lastLocation);
System.out.println("109");
pstmt.setString(10,designation);
System.out.println("110");
pstmt.setBoolean(11,isResigned);
System.out.println("111");
pstmt.executeUpdate();
pstmt.close();
pstmt=null;
}catch(SQLException ex){System.out.println("Exception:"+ex);response.sendRedirect("index.jsp");}
catch(Exception ex){System.out.println("Super Exception:"+ex);response.sendRedirect("index.jsp");}
finally{
}
}
}
thanks