• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with datetime fields

 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all...
I am using JSP page to insert a date time field into an SQL Server 2000 database. I am not able to do it. Can any1 tell me how to do it. I'll be thankful if he/she can provide a small example. I am providing the code I am using...
My Scenario...
===============
I have a 3 combo boxes showing Day (1 to 31), Month (Jan to Dec) and Year (1970 to 2020). Now in my JSP file I have written...

String strDay=request.getParameter("day");
String strMon=request.getParameter("month");
String strYr=request.getParameter("year");
String dob=strDay+"-"+strMon+"-"+strYr;

In my database operation part (i have used PreparedStatement interface), I have written...
PST.setDate(2,dob);
I cannot insert it ... please some1 help me..
N Nanda
 
eammon bannon
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I cannot insert it ... please some1 help me..

Hmm. Not very descriptive. Post your error, then we can help.
[ April 06, 2004: Message edited by: eammon bannon ]
 
N Nanda
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your response, I am getting following error...

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP
An error occurred at line: 40 in the jsp file: /jsp/project/manage_personal.jsp
Generated servlet error:
[javac] Compiling 1 source file
C:\Apache\Tomcat5\work\Catalina\localhost\nnsweb\org\apache\jsp\jsp\project\manage_005fpersonal_jsp.java:92: cannot resolve symbol
symbol : method setDate (int,java.lang.String)
location: interface java.sql.PreparedStatement
PST.setDate(4,strDate);
^
1 error

org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:127)
org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:351)
org.apache.jasper.compiler.Compiler.generateClass(Compiler.java:415)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:458)
org.apache.jasper.compiler.Compiler.compile(Compiler.java:439)
org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:552)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:291)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:301)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:248)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
 
Bikramjit Singh Bajwa
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have noticed that you are passing wrong argument in setDate Method of PreparedStatement. Bellow is the exact method:
setDate(int indexNumber, javax.sql.Date date);
and you are passing
setDate(int indexNumber, String date);
I hope this will solve your problem. Make sure pass javax.sql.Date object not java.util.Date object.
buuurraaaaaaaa...
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64623
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the JDBC forum.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic