this is the method to access database and when ever i excute my web app server log is as followsCode :private String available_stmt = "select tickets from shows where show_name =? and tid=? and showdate=?"; public int availablity(String theater, String show, java.sql.Date date) { int i = -1; try { Context ctx = new InitialContext(); if (ctx == null) { throw new RuntimeException("JNDI Contex could not be found"); } ds = (DataSource) ctx.lookup("java:comp/env/jdbc/mindu"); if (ds == null) { throw new RuntimeException("Datasource could not be found"); } // get a database connection connection = ds.getConnection(); stmt = connection.prepareStatement(available_stmt); stmt.setString(1, show); System.out.println("show set"); stmt.setInt(2, objectid(theater)); System.out.println("tid set"+objectid(theater)); System.out.println("date recieved "+date); stmt.setDate(3,date); System.out.println("date set"); results = stmt.executeQuery(); while (results.next()) { i = (results.getInt("tickets")); } return i; } catch (SQLException sqle) { throw new RuntimeException("A Database error occured." + sqle.getMessage()); } catch (NamingException ne) { throw new RuntimeException("A JNDI error occured" + ne.getMessage()); } }
Note: i tried excuting the same sql string in sql server and it worked there!!Quote:
show set
tid set1
date recieved 2011-03-22
Oct 12, 2011 4:15:16 PM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet [action] in context with path [/rainbow] threw exception
java.lang.RuntimeException: A Database error occured.Parameter index out of range (3 > number of parameters, which is 1).
at model.theaterDAO.availablity(theaterDAO.java:216)
at formbeans.eupdatebean.exceed(eupdatebean.java:88)
at formbeans.eupdatebean.validate(eupdatebean.java:75 )
at org.apache.struts.action.RequestProcessor.processV alidate(RequestProcessor.java:945)
at org.apache.struts.action.RequestProcessor.process( RequestProcessor.java:198)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:641)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:722)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at org.netbeans.modules.web.monitor.server.MonitorFil ter.doFilter(MonitorFilter.java:393)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:243)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBas e.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(A ccessLogValve.java:563)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:399)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:317)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:204)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProce ssor.run(JIoEndpoint.java:311)
at java.util.concurrent.ThreadPoolExecutor.runWorker( ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
i tried many things, even googled it but not having any luck.

