my dog learned polymorphism*
The moose likes JDBC and the fly likes java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not " Watch "java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not " New topic
Author

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not

Vijay Kumar
Ranch Hand

Joined: Jul 24, 2003
Posts: 260
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
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The Exception is telling you all you need to know: your driver does not support the setLong() method. Remember that the core of JDBC is basically a bunch of interfaces, and it is up to Driver implementer to add support for the functionality included in these interfaces. If they can't/won't then which ever method will throw an UnsupportedOperationException.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

"javasavvy", please read the warning about your display name here. Accounts with invalid display names get deleted, often withour warning

Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver]Optional feature not
 
Similar Threads
Connecting to a database through servl
doubts in setDate(i,date,cal) API of preparedStatement
ejbLoad is not getting called
MS Access NullPointerException
PreparedStatment - Search Page