RE: Parsing text to date - Urgent
Look in the JDBC API reference. The message you are receiving means exactly what it says: there is no constructor for class java.sql.Date that takes a String for a parameter. You'll need to use one of the available constructors. Probably the easiest is to parse your String into three integers representing day, month and year. -Original Message- From: Venkata Ratnam Vadlamannati [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 20, 2001 8:19 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Parsing text to date - Urgent Dear All I am taking date from an HTML form in 01/01/2001 format and take read this in a jsp page as request.getParameter("date") I try to put this in my MSSQL Server 7 table (table column is date with 8 characters width - default) with a prepared statement, it gives the following error: *** Error: 500 Location:/tests/test2.jsp Internal Servlet Error: org.apache.jasper.JasperException: Unable to compile class for JSPD:\tomcat\work\localhost_8080%2Ftests\_0002ftest_00032_0002ejsptest2_jsp_ 3.java:194: Incompatible type for method. Can't convert java.lang.String to java.sql.Date. ps.setDate(2,request.getParameter("publishdate")); ^ D:\tomcat\work\localhost_8080%2Ftests\_0002ftest_00032_0002ejsptest2_jsp_3.j ava:195: Incompatible type for method. Can't convert java.lang.String to java.sql.Date. ps.setDate(3,request.getParameter("archivedate")); ^ 2 errors at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254) at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:453) at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:424) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspSe rvlet.java:152) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:164) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:382) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387) at org.apache.tomcat.core.Handler.service(Handler.java:263) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:74 9) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:695) at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection (Ajp12ConnectionHandler.java:166) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:403) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) *** Can anybody suggest me as how do I put this into my table Thanks in advance Venkat mail to: [EMAIL PROTECTED] __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
RE: Parsing text to date - Urgent
I had this same problem with an informix db server. I did the following to convert the string into a 'java.sql.Date' /* parses the string as a date and returns a 'java.util.Date' NOT 'java.sql.Date'. if string can't be parsed it throws a ParseException. */ java.util.Date temp = DateFormat.parse(request.getParameter("publishdate"); /* this is the only way that I have found to convert 'java.util.Date' to it's sub-class 'java.sql.Date'. */ /* the getTime() method returns the date as seconds since the epoch, and there is a constructor for 'java.sql.Date' that takes that information as a parameter. */ java.sql.Date date = new java.sql.Date(temp.getTime()); /* now you can insert your date in the query. */ ps.setDate(2, date); -Original Message- From: Venkata Ratnam Vadlamannati [mailto:[EMAIL PROTECTED]] Sent: Saturday, January 20, 2001 8:19 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Parsing text to date - Urgent Dear All I am taking date from an HTML form in 01/01/2001 format and take read this in a jsp page as request.getParameter("date") I try to put this in my MSSQL Server 7 table (table column is date with 8 characters width - default) with a prepared statement, it gives the following error: *** Error: 500 Location:/tests/test2.jsp Internal Servlet Error: org.apache.jasper.JasperException: Unable to compile class for JSPD:\tomcat\work\localhost_8080%2Ftests\_0002ftest_00032_0002ejsp test2_jsp_3.java:194: Incompatible type for method. Can't convert java.lang.String to java.sql.Date. ps.setDate(2,request.getParameter("publishdate")); ^ D:\tomcat\work\localhost_8080%2Ftests\_0002ftest_00032_0002ejsptes t2_jsp_3.java:195: Incompatible type for method. Can't convert java.lang.String to java.sql.Date. ps.setDate(3,request.getParameter("archivedate")); ^ 2 errors at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254) at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:453) at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:424) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNeces sary(JspServlet.java:152) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(Jsp Servlet.java:164) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:382) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387) at org.apache.tomcat.core.Handler.service(Handler.java:263) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371) at org.apache.tomcat.core.ContextManager.internalService(ContextManag er.java:749) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:695) at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.process Connection(Ajp12ConnectionHandler.java:166) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:403) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) *** Can anybody suggest me as how do I put this into my table Thanks in advance Venkat mail to: [EMAIL PROTECTED] __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]
Re: Parsing text to date - Urgent
couple of things, 1. Don't cross post this to three different lists. Tomcat dev is for the developers of tomcat and development related issues. 2. Try to convert your string into a Date before you pass it into the prepared statement. A Date object is not of the same class as a String object. Date date = convertyMyStringToDate(string) ps.setDate(3,date) Filip ~ Namaste - I bow to the divine in you. ~ Filip Hanik Technical Architect [EMAIL PROTECTED] - Original Message - From: "Venkata Ratnam Vadlamannati" [EMAIL PROTECTED] To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Saturday, January 20, 2001 5:18 AM Subject: Parsing text to date - Urgent Dear All I am taking date from an HTML form in 01/01/2001 format and take read this in a jsp page as request.getParameter("date") I try to put this in my MSSQL Server 7 table (table column is date with 8 characters width - default) with a prepared statement, it gives the following error: *** Error: 500 Location:/tests/test2.jsp Internal Servlet Error: org.apache.jasper.JasperException: Unable to compile class for JSPD:\tomcat\work\localhost_8080%2Ftests\_0002ftest_00032_0002ejsptest2_jsp_ 3.java:194: Incompatible type for method. Can't convert java.lang.String to java.sql.Date. ps.setDate(2,request.getParameter("publishdate")); ^ D:\tomcat\work\localhost_8080%2Ftests\_0002ftest_00032_0002ejsptest2_jsp_3.j ava:195: Incompatible type for method. Can't convert java.lang.String to java.sql.Date. ps.setDate(3,request.getParameter("archivedate")); ^ 2 errors at org.apache.jasper.compiler.Compiler.compile(Compiler.java:254) at org.apache.jasper.servlet.JspServlet.doLoadJSP(JspServlet.java:453) at org.apache.jasper.servlet.JasperLoader12.loadJSP(JasperLoader12.java:146) at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:424) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspSe rvlet.java:152) at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.ja va:164) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:309) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:382) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:387) at org.apache.tomcat.core.Handler.service(Handler.java:263) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:371) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java:74 9) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:695) at org.apache.tomcat.service.connector.Ajp12ConnectionHandler.processConnection (Ajp12ConnectionHandler.java:166) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:403) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:498) at java.lang.Thread.run(Thread.java:484) *** Can anybody suggest me as how do I put this into my table Thanks in advance Venkat mail to: [EMAIL PROTECTED] __ Do You Yahoo!? Yahoo! Auctions - Buy the things you want at great prices. http://auctions.yahoo.com/ - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, email: [EMAIL PROTECTED]