tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Lee Deliang" <just_dar...@hotmail.com>
Subject Re: I am really stumped at this one any1?
Date Tue, 11 Jul 2000 10:07:58 GMT
hi,

    yeah it works without the single quotes. thanks every1. I got another 
bug that sprang out. I suspect it is my sql statement's logic. check this 
out:

String SQLstatement = "SELECT courseNo FROM Course WHERE  courseNo != 
ALL(SELECT courseNo FROM ApplicationRecord WHERE userNRIC = '" + userNRIC + 
"' ) GROUP BY courseNo HAVING courseDeadline > ? AND courseCapacity > 0 ";

The ? is later set in with an Timestamp object i created later on and works 
fine. The problem I have is that my program does not do wat i want it to do. 
I want it to display courses which the current user HAS NOT booked for 
before. Records of bookings are kept in ApplicationRecord and all the 
courses are kept in Courses. Can anyone tell me what is wrong with my 
statement?

Darren

>From: Rick Bosch <rbosch@actv.com>
>Reply-To: tomcat-user@jakarta.apache.org
>To: tomcat-user@jakarta.apache.org
>Subject: Re: I am really stumped at this one any1?
>Date: Mon, 10 Jul 2000 11:56:32 -0400
>
>personally i've never used quotes around the question mark,
>
>try
>
>  String SQLstatement ="INSERT INTO ApplicationRecord VALUES(?, ?, ?, ?,
>  ?, ?, ?, ?, ?, ?, ?, ?,?, ?, ?, ?, ?, ?)";
>
>rick
>
>please let me know what the problem turns out to be
>
>----------
> >From: "Darren Lee Deliang" <just_darren@hotmail.com>
> >To: tomcat-user@jakarta.apache.org
> >Subject: I am really stumped at this one any1?
> >Date: Mon, Jul 10, 2000, 2:12 PM
> >
>
> >
> > I have problems trying to write data into my MS SQL Server database. 
>Here is
> > the codes in my java bean that calls and writes to it:
> >
> > String SQLstatement ="INSERT INTO ApplicationRecord VALUES('?', '?', 
>'?', ?,
> > ?, ?, ?, ?, ?, ?, ?, '?', '?', ?, ?, ?, '?', '?')";
> >
> > try
> > {
> >  addcon.setAutoCommit(false);
> >  PreparedStatement stm = addcon.prepareStatement(SQLstatement);
> >  stm.setString(1, getAppNo());
> >  stm.setString(2, getUserNRIC());
> >  stm.setString(3, getCourseNo());
> >  stm.setDouble(4, appmanHrs);
> >  stm.setInt(5, appmanDays);
> >  stm.setTimestamp(6, appstartDate);
> >  stm.setTimestamp(7, appendDate);
> >  stm.setTimestamp(8, appDeadline);
> >  stm.setDouble(9, getAppFees());
> >  stm.setDouble(10, appfeesPaid);
> >  stm.setDouble(11, getAppotherCosts());
> >  stm.setString(12, getAppclaimDetails());
> >  stm.setString(13, getAppRemarks());
> >  stm.setBoolean(14, appsupervisorApproval);
> >  stm.setBoolean(15, appdirectorApproval);
> >  stm.setBoolean(16, appAttendance);
> >  stm.setString(17, appsuperNRIC);
> >  stm.setString(18, appdirectorNRIC);
> >
> >  stm.executeUpdate();
> >  System.out.println(" Inserting Data Successful");
> >
> >  addcon.commit();
> >  con.setAutoCommit(true);
> >
> >  stm.close();
> >  addcon.close();
> > }
> > catch(SQLException ex)
> > {
> >  System.err.println("SQLException: " + ex.getMessage());
> >  if(addcon != null)
> >  {
> >   try
> >   {
> >    System.err.println("Transaction is being rolled back");
> >    addcon.rollback();
> >   }
> >   catch(SQLException excep)
> >   {
> >    System.err.println("SQLException: " + excep.getMessage());
> >   }
> >  }
> > }
> >
> > i get the following error in my browser:
> >
> > Internal Servlet Error:
> >
> > javax.servlet.ServletException
> >  at
> >
>org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImp
>l.java:38
> > 6)
> >  at
> >
>jsp.RetrainingWebApp._0002fjsp_0002fRetrainingWebApp_0002fconfirmed_0002ejsp
>confirmed
> >
>_jsp_1._jspService(_0002fjsp_0002fRetrainingWebApp_0002fconfirmed_0002ejspco
>nfirmed_j
> > sp_1.java:124)
> >  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >  at
> >
>org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
>va:174)
> >  at 
>org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
> >  at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >  at
> > 
>org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> >  at 
>org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> >  at
> >
>org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
>onnection
> > Handler.java:160)
> >  at
> > 
>org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
> >  at java.lang.Thread.run(Unknown Source)
> >
> > Root cause:
> > java.lang.ArrayIndexOutOfBoundsException
> >  at sun.jdbc.odbc.JdbcOdbcPreparedStatement.clearParameter(Unknown 
>Source)
> >  at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setNull(Unknown Source)
> >  at sun.jdbc.odbc.JdbcOdbcPreparedStatement.setString(Unknown Source)
> >  at Retraining.ApplyCourses.addRecord(ApplyCourses.java:374)
> >  at
> >
>jsp.RetrainingWebApp._0002fjsp_0002fRetrainingWebApp_0002fconfirmed_0002ejsp
>confirmed
> >
>_jsp_1._jspService(_0002fjsp_0002fRetrainingWebApp_0002fconfirmed_0002ejspco
>nfirmed_j
> > sp_1.java:91)
> >  at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:126)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >  at
> >
>org.apache.jasper.runtime.JspServlet$JspServletWrapper.service(JspServlet.ja
>va:174)
> >  at 
>org.apache.jasper.runtime.JspServlet.serviceJspFile(JspServlet.java:261)
> >  at org.apache.jasper.runtime.JspServlet.service(JspServlet.java:369)
> >  at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
> >  at
> > 
>org.apache.tomcat.core.ServletWrapper.handleRequest(ServletWrapper.java:503)
> >  at 
>org.apache.tomcat.core.ContextManager.service(ContextManager.java:559)
> >  at
> >
>org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(HttpC
>onnection
> > Handler.java:160)
> >  at
> > 
>org.apache.tomcat.service.TcpConnectionThread.run(SimpleTcpEndpoint.java:338)
> >  at java.lang.Thread.run(Unknown Source)
> >
> > Can any1 kindly tell me what is wrong?
> >
> > Darren
> > ________________________________________________________________________
> > Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com

________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com


Mime
View raw message