AppletTalk.com Forum Index AppletTalk.com
Java discussions newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problem while retrieving values from MS Access from jsp usin

 
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases
View previous topic :: View next topic  
Author Message
jemima
Guest





PostPosted: Mon Feb 02, 2004 10:09 pm    Post subject: Problem while retrieving values from MS Access from jsp usin Reply with quote



hi

i want to get record from database(MS Access) which are entered in
specific month.
i've one html file with:

<select name="MonSur">
<option value="Jan" selected>January
<option value="Feb" >Feburary
<option value="Mar">March
<option value="Apr">April
<option value="May">May
<option value="Jun">June
<option value="Jul">July
<option value="Aug">August
<option value="Sep">September
<option value="Oct">October
<option value="Nov">November
<option value="Dec">December
</select>

my jsp files has the following code:
<%

String MonSur=request.getParameter("MonSur");

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection Conn = DriverManager.getConnection("jdbc:odbc:Surveypage");
//Creating the Connection Statement
Statement stmt = Conn.createStatement();
ResultSet rs=null;
//Query
String StrQuery ="SELECT * from surveytable where
Format(sdate,"mmm") = ""+ MonSur + "";";//what i try to do here is
"want only values of specific month(MonSur)"
//Format(sdate,"mmm") -i used this thing for retrieving only month
from
//sdate(database field-set using date())
//everything else working properly.
%>
Error:
exception

javax.servlet.ServletException: [Microsoft][ODBC Microsoft Access
Driver] Too few parameters. Expected 2.
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:867)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:800)
org.apache.jsp.Survey.Report_jsp._jspService(Report_jsp.java:886)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
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)


root cause

java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Too
few parameters. Expected 2.
sun.jdbc.odbc.JdbcOdbc.createSQLException(JdbcOdbc.java:6958)
sun.jdbc.odbc.JdbcOdbc.standardError(JdbcOdbc.java:7115)
sun.jdbc.odbc.JdbcOdbc.SQLExecDirect(JdbcOdbc.java:3111)
sun.jdbc.odbc.JdbcOdbcStatement.execute(JdbcOdbcStatement.java:338)
sun.jdbc.odbc.JdbcOdbcStatement.executeQuery(JdbcOdbcStatement.java:253)
org.apache.jsp.Survey.Report_jsp._jspService(Report_jsp.java:86)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:133)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:311)
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)

hope to get some help soon.
Back to top
Mike Sherrill
Guest





PostPosted: Mon Feb 02, 2004 11:50 pm    Post subject: Re: Problem while retrieving values from MS Access from jsp Reply with quote



On 2 Feb 2004 14:09:15 -0800, [email]jemydpm (AT) yahoo (DOT) co.in[/email] (jemima) wrote:

Quote:
i want to get record from database(MS Access) which are entered in
specific month.

Ok.

[snip]
Quote:
String StrQuery ="SELECT * from surveytable where
Format(sdate,"mmm") = ""+ MonSur + "";";//what i try to do here is
"want only values of specific month(MonSur)"

When you print the value of StrQuery, is it a valid SQL statement?
Show me.

FWIW, if you try to put this in production in most shops, the DBA will
hunt you down and kill you. Use BETWEEN ... AND ... in the WHERE
clause instead.

--
Mike Sherrill
Information Management Systems

Back to top
Display posts from previous:   
Post new topic   Reply to topic    AppletTalk.com Forum Index -> Java and Databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.