Stella Yulianti

Greenhorn
+ Follow
since Jun 03, 2007
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Stella Yulianti

Hello.. newbie needs help in inserting Date/Time in JSP and Ms.Access..
I've tried using simpleDateFormat but it didn't work either..

this is my JSP form code

<td class="style3">:
<input name="date" type="text" id="date" value="<% org.joda.time.DateTime dt = new org.joda.time.DateTime();%>
<%= dt.toString("yyyy-MM-dd hh:mm:ss") %>" size="50" readonly="true"></td>



this is my JSP insert code

<%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
<%

String date = request.getParameter("PostDate");
String name = request.getParameter("Name");
String email = request.getParameter("Email");
String msg = request.getParameter("Message");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ="+application.getRealPath("/WEB-INF/data.mdb");
Connection con = DriverManager.getConnection(url);
Statement state = con.createStatement();

String query = "insert into GuestBook values ('" + date + "','"+ name + "','" + email + "','" + msg + "')";

state.executeUpdate(query);
response.sendRedirect("guestbook.jsp");
%>



and the result

root cause

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:858)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:791)
org.apache.jsp.insertGuestBook_jsp._jspService(insertGuestBook_jsp.java:69)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:332)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:314)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:264)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:368)