SetTimestamp on prepared statement returns SQLException

I have to synchronize data between our new web app and a legacy app. The legacy app can't handle null dates in SQL so all blank dates are saved as 1753-01-01 00:00:00.000.
I have (relevant parts):
ps.setTimestamp(i++, safeTime(rs.getTimestamp("DOT"))); private Timestamp safeTime(Timestamp t) { Calendar noCal = Calendar.getInstance(); noCal.clear(); noCal.set(1753, Calendar.JANUARY, 1); noTime = new Timestamp(noCal.getTimeInMillis()); if (t == null) return noTime; return t; }
It throws a SQLException error Only dates between January 1, 1753 and December 31, 9999 are accepted. I checked the field for DOT and it is null. noTime on this record returns a timestamp of -6847804800000. safeTime printed to the console returns 1753-01-01 00:00:00.0. I'm at a loss. I'm trying to set a timestamp in the prepared statement of January 1, 1753, but it's telling me it's outside of the date range??? What could be wrong?
Thanks

Hmmm, version, not sure how to find that out. Server.xml has:
<Resource auth="Container" 
       driverClassName="net.sourceforge.jtds.jdbc.Driver" 
       maxActive="100" maxIdle="30" maxWait="10000" name="jdbc/Desk" password="xxxxxx" removeAbandoned="true" removeAbandonedTimeout="30" type="javax.sql.DataSource" 
       url="jdbc:jtds:sqlserver://192.168.123.2:1433" username="xxxxx"/> Stack:
java.sql.SQLException: Only dates between January 1, 1753 and December 31, 9999 are accepted.
     at net.sourceforge.jtds.jdbc.DateTime.packDate(DateTime.java:300)
     at net.sourceforge.jtds.jdbc.DateTime.<init>(DateTime.java:121)
     at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setParameter(JtdsPreparedStatement.java:445)
     at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.setTimestamp(JtdsPreparedStatement.java:841)
     at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.setTimestamp(DelegatingPreparedStatement.java:143)
     at desk.desk.DataSynchAction.updateEmployee(DataSynchAction.java:888)
     at desk.desk.DataSynchAction.updateEmployees(DataSynchAction.java:785)
     at desk.desk.DataSynchAction.execute(DataSynchAction.java:103)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
     at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
     at java.lang.reflect.Method.invoke(Unknown Source)
     at com.opensymphony.xwork.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:364)
     at com.opensymphony.xwork.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:216)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:190)
     at com.opensymphony.xwork.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:168)
     at com.opensymphony.xwork.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:115)
     at com.opensymphony.xwork.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.webwork.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:171)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.webwork.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:147)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:151)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:186)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.interceptor.AroundInterceptor.intercept(AroundInterceptor.java:31)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at desk.desk.SecurityCheck.intercept(SecurityCheck.java:29)
     at com.opensymphony.xwork.DefaultActionInvocation.invoke(DefaultActionInvocation.java:188)
     at com.opensymphony.xwork.DefaultActionProxy.execute(DefaultActionProxy.java:113)
     at com.opensymphony.webwork.dispatcher.DispatcherUtils.serviceAction(DispatcherUtils.java:225)
     at com.opensymphony.webwork.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:202)
     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:230)
     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
     at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:525)
     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:104)
     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:261)
     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:844)
     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:581)
     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
     at java.lang.Thread.run(Unknown Source)If I set the timestamp to 0, I would still need to set it to 01/01/1753 in the legacy db.

Similar Messages

  • Oracle Prepared Statement and spaces in field

    I have a field that is defined as char(10). It has characters like '39' in it. When I select against it using standard SQL (where clause) I get results. When I use it in the where clause of a prepared statement it does not return any rows.
    If I have the field defined as char(2) the prepared statement works.
    If I have the field defined as varchar2(10) and loaded with '39' the prepared statement works.
    If I have the field defined as varchar2(10) and loaded with '39 ' the prepared statement returns no results.
    I really do not think this is a JDBC problem. However, since Oracle's site basically <expletive deleted>, I am hoping someone here has a solution.
    Thanks in advance if you can help.

    Let me clarify.
    I cannot remove the whitespace from the data in the database. I do not need the whitespace to do the query if I am not using a Prepared Statement. This seems to be a problem with the way Oracle is handling the prepared statement. (hence.. my thinking that this is really not a JDBC problem at all.. but I could be wrong.)

  • Prepared statement and DELETE returns 0 count

    when executing an oracle prepared statement, the count returned is allways 0 for DELETE. However, if doing an INSERT, the count returned is correct
    public void CreatePreparePurgeRcdSetArray(String sql, int i, int max, boolean create) throws SQLException,Exception
    if (create == true)
              if (preparedStatementArray == null)
                   preparedStatementArray = new PreparedStatement[max];
              int scroll_type = getScrollType();
                   if (sql.compareTo("NOT_USED") == 0)
                        preparedStatementArray[i] = null;
                   else
                        preparedStatement          = (connClass.getConn()).prepareStatement(sql);
                        preparedStatementArray[i] = preparedStatement;
                        preparedStatement          = null;
    else
         closePrepareStatementArray(max);
    public int UpdatePreparePurgeRcdSet(Vector smry, String sqlP, int i) throws SQLException,Exception
         Object[] searchs = (Object[])smry.elementAt(0);
         /*java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
         String aaa = searchs[1].toString();
         String aab = searchs[1].toString();
         java.util.Date                     dtx = sdf.parse(aaa);
         java.util.Date                     dty = sdf.parse(aab);
         oracle.sql.DATE aa1 = new DATE(new Timestamp(dtx.getTime()));
         oracle.sql.DATE aa2 = new DATE(new Timestamp(dty.getTime()));
         java.sql.Timestamp      ts1 = (java.sql.Timestamp) searchs[1] ;
         java.sql.Timestamp      ts2 = (java.sql.Timestamp) searchs[5] ;
         boolean oracle = true;
         boolean debug = true;
              if ((oracle == true) && (debug == true))
                   String sql1 = "INSERT INTO FFI_MASTER_PURGE_TBL values ('lmill', 'OSTDEVT', 'sdsadmin', ?, 30, 60, '0', 2, 'ZZZ', ' ')";
                   String sql2 = "DELETE FROM TDSADMIN.FFI_MASTER_PURGE_TBL where FORMATCATEGORY = ?";
                   String sql3 = "DELETE from TDSADMIN.SUMMARY_TBL where (ML_STI_SRC_SYS_CD = ?) AND (ML_STI_CYCLE_CD = ?) AND (ML_STI_FILE_ID = ?)";
                   preparedStatement = (connClass.getConn()).prepareStatement(sql3);
                   //preparedStatement.setString(1, "test");
                   preparedStatement.setString(1, "618");
                   preparedStatement.setString(2, "0114200601");
                   preparedStatement.setString(3, "00001591");
                   oraclePreparedStatement = (OraclePreparedStatement)preparedStatement;
                   recsDeleted = oraclePreparedStatement.executeUpdate();
              if (oracle == true)
              preparedStatement = preparedStatementArray;
              //oraclePreparedStatement.setExecuteBatch (3);
              // ML_STI_SRC_SYS_CD
              preparedStatement.setString(1, searchs[0].toString());
                   // ML_STI_SRCSYS_DTTM
              //preparedStatement.setTimestamp(2, ts1);
              //preparedStatement.setObject(2, aa1);
              // ML_STI_CYCLE_CD
              preparedStatement.setString(2, searchs[2].toString());
                   // ML_STI_FILE_ID
              preparedStatement.setString(3, searchs[3].toString());
                   // ML_STI_LOAD_DTTM
              //preparedStatement.setTimestamp(5, ts2);
              //preparedStatement.setObject(5, aa2);
         else
                   preparedStatement = preparedStatementArray[i];
              // ML_STI_SRC_SYS_CD
              preparedStatement.setString(1, searchs[0].toString());
                   // ML_STI_SRCSYS_DTTM
              preparedStatement.setTimestamp(2, ts1);
              // ML_STI_CYCLE_CD
              preparedStatement.setString(3, searchs[2].toString());
                   // ML_STI_FILE_ID
              preparedStatement.setString(4, searchs[3].toString());
                   // ML_STI_LOAD_DTTM
              preparedStatement.setTimestamp(5, ts2);
         DateClass dateClass = new DateClass();
              String startTime = dateClass.calToFormattedDateExact();
              try
                   if (oracle == true)
                        //int batch_val = oraclePreparedStatement.getExecuteBatch();
                        oraclePreparedStatement = (OraclePreparedStatement)preparedStatement;
                        recsDeleted = oraclePreparedStatement.executeUpdate();
                        //recsDeleted = oraclePreparedStatement.sendBatch();
                   else
                        recsDeleted = preparedStatement.executeUpdate();
    catch(SQLException e)
         String err = (e.getMessage()).substring(0,e.getMessage().length()-1);
         systemClass.logSqlStatement(sqlP + " : " + err, startTime);
    throw e;
    Message was edited by:
    user539085
    Message was edited by:
    user539085
    Message was edited by:
    user539085

    user539085,
    I guess it returns 0 (zero) because it doesn't delete anything. Can you verify that it did delete some records and still returned zero?
    Good Luck,
    Avi.

  • How do I handle NULL returns from prepared statement?

    Thanks in advance to all those who respond. As a beginner with Java/JSP/JDBC, I need all the help I can get!
    Here's the problem...
    I'm using a prepared statement in JSP to query a MySQL database.
    If there is a value to return, everything works properly.
    If the query returns a NULL (empty set) value, I get the following error:
    javax.servlet.ServletException: Before start of result set
    Here's the code (no negative comments please...I know I'm violating some conventions! I'll restructure it later. Right now I just need help with handling the NULL case):
    <%
    Driver DriverAppt = (Driver)Class.forName(MM_test_DRIVER).newInstance();
    Connection ConnAppt = DriverManager.getConnection(MM_test_STRING,MM_test_USERNAME,MM_test_PASSWORD);PreparedStatement StatementAppt = ConnAppt.prepareStatement("SELECT lastname FROM appts_pid1 WHERE user_id = " + Recordset1__MMColParam + " AND year = " + yy + " AND month = '" + months[mm] + "' AND date = " + dates[dd] + " AND appttime = '16:15:00'");
    ResultSet Appt = StatementAppt.executeQuery();
    boolean Appt_isEmpty = !Appt.first();
    boolean Appt_hasData = !Appt_isEmpty;
    Object Appt_data;
    int Appt_numRows = 0;
    %>
    Thanks for the help!!!

    I think I have a better handle on what's occurring here. To cut to the heart of the problem, I'm going to give a very simple example that illustrates what type of error handling I need.
    HERE'S THE EXAMPLE:
    Let's say that I have a database of users. There are only two columns in the database: user_id and lastname. There are only 2 users, user_id "1" has lastname "Jones" and user_id "2" has lastname "Smith".
    I built a very simple web interface that let's a user enter a number to see if there's a lastname associated with that record. The user has no way of knowing if the user_id exists or not, so they may or may not enter a valid number.
    If the user enters a valid user_id (in this case "1" or "2"), then the correct lastname is displayed. If the user enters an invalid user_id (in this case, anything other than "1" or "2") then I get the same "Before start of result set" error that I'm getting in my real application.
    So, the question is: WHERE IN THIS CODE WOULD I HANDLE THE RETURN OF AN EMPTY SET?
    The goal here is to have the sentence say "The user's lastname is .", basically returning null. If there has to be a value, then have the last sentence say "The user's lastname is unknown."
    If you can solve this simple example, you'll have also solved the problem with my main application!!!! :-)
    Here's the example code:
    <%@ page contentType="text/html; charset=iso-8859-1" language="java" import="java.sql.*" errorPage="" %>
    <%@ include file="Connections/example.jsp" %>
    <%
    String Recordset1__MMColParam = "1";
    if (request.getParameter("user_id") !=null) {Recordset1__MMColParam = (String)request.getParameter("user_id");}
    %>
    <%
    Driver DriverRecordset1 = (Driver)Class.forName(MM_example_DRIVER).newInstance();
    Connection ConnRecordset1 = DriverManager.getConnection(MM_example_STRING,MM_example_USERNAME,MM_example_PASSWORD);
    PreparedStatement StatementRecordset1 = ConnRecordset1.prepareStatement("SELECT * FROM test_table WHERE user_id = " + Recordset1__MMColParam + "");
    ResultSet Recordset1 = StatementRecordset1.executeQuery();
    boolean Recordset1_isEmpty = !Recordset1.next();
    boolean Recordset1_hasData = !Recordset1_isEmpty;
    Object Recordset1_data;
    int Recordset1_numRows = 0;
    %>
    <html>
    <head>
    <title>Untitled Document</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    </head>
    <body>
    <form action="test.jsp" method="get" enctype="application/x-www-form-urlencoded" name="form1" target="_self">
    <p> Submit a user id and a lastname will be displayed.</p>
    <p>
    <input type="text" name="user_id">
    <input type="submit" name="" value="Submit">
    </p>
    </form>
    <p>The User's lastname is <%=(((Recordset1_data = Recordset1.getObject("lastname"))==null || Recordset1.wasNull())?"":Recordset1_data)%>.</p>
    </body>
    </html>
    <%
    Recordset1.close();
    StatementRecordset1.close();
    ConnRecordset1.close();
    %>
    A huge "THANK YOU!!!!" to all those who've helped me here!!!

  • Jboss getting SQLException: Closed Statement prepared-statement- cache-size

    My first post in this forum , hope to get a quick resolution :)
    I am using Jboss 4.0.0 on Oracle 9.2.0.4.0
    In order to improve the app performance , I had specified prepared-statement-cache-size as 50 as follows ,
    <datasources>
    <local-tx-datasource>
    <jndi-name>jdbc/sct</jndi-name> <connection-url>jdbc:oracle:thin:@confidential:1560:sct1</connection-url>
    <user-name>Confidential</user-name>
    <password>Confidential</password>
    <min-pool-size>10</min-pool-size>
    <max-pool-size>120</max-pool-size>     <prepared-statement-cache-size>50</prepared-statement-cache-size>
    <exception-sorter-class-name>org.jboss.resource.adapter.jdbc.vendor.OracleExceptio nSorter</exception-sorter-class-name>
    <idle-timeout-minutes>5</idle-timeout-minutes>
    <track-statements>true</track-statements>
    <new-connection-sql>select sysdate from dual</new-connection-sql>
    <check-valid-connection-sql>select sysdate from dual</check-valid-connection-sql>
    </local-tx-datasource>
    </datasources>
    After doing this , I start getting the following exception ,
    java.sql.SQLException: Closed Statement
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:180)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:222)
         at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:285)
         at oracle.jdbc.driver.OracleStatement.ensureOpen(OracleStatement.java:5681)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.j ava:409)
         at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.ja va:366)
         at org.jboss.resource.adapter.jdbc.CachedPreparedStatement.executeQuery(CachedPrepare dStatement.java:57)
         at org.jboss.resource.adapter.jdbc.WrappedPreparedStatement.executeQuery(WrappedPrepa redStatement.java:296)
         at com.ge.sct.SiteText.getSiteTextFromDB(SiteText.java:292)
    Thanks in Advance
    Bhavin

    Hello,
    I am also facing the same error: somewhere just now I read,
    We were getting this error on JBoss / Oracle. The fix was setting the following to 0 in oracle-ds.xml:
    <prepared-statement-cache-size>0</prepared-statement-cache-size>
    Ref: http://www.jpox.org/servlet/forum/viewthread?thread=1108
    May be you can try this, I am also still finding the solution, I will try the above and let u know, if i get success.
    Regards,
    Rajesh

  • Date objects and prepared statements

    Hi, I am trying to parse a String into a Date object with format "dd/MM/yyyy hh/mm/ss". Anyway, i have a method in a separate class which reads in a String and converts it to a formatted Date object.
    static public Date convertToDate(String t) throws ParseException {
    Date dd = new Date();
    ParsePosition p = new ParsePosition(0);
    SimpleDateFormat formatter = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
    //y, M, etc are retrieved as substrings of String t. I know these methods are deprecated as well
    dd.setYear(y);
    dd.setMonth(M);
    dd.setDate(d);
    dd.setHours(h);
    dd.setMinutes(m);
    dd.setSeconds(s);
    String formattedDate = formatter.format(dd);
    Date theDate = formatter.parse(formattedDate);
    return theDate;
    Anyway, I am trying to use this in an SQL statement because I am using an Access DB which has a field of Date/Time value. Is this correct to use a Date object then? I have a prepared statement -
    PreparedStatement query = connection.prepareStatement(
    "SELECT FText FROM wnioutput WHERE Id = ? AND Section = ? AND Start = " +
    "? AND Field = ?");
    //start is the Date object returned from the previous method in a separate class
    query.setInt(1, id);
    query.setInt(2, section);
    query.setDate(3, formattedStart); - with this part, i get a setDate method not found, or something
    query.setString(4, ch);
    Can anybody tell me what the problem is? I know there are Date objects of java.util and java.sql. Should i be using an sql Date object? And if so, how, and where do I do this? Thank you!

    ok, i just tried
    query.setTimestamp(3, new java.sql.Timestamp(formattedStart.getTime()));
    where formattedStart is a java.util.Date object
    and I get the following error message -
    Error occured in getting endDateAndTime: java.sql.SQLException: Exception in databaseDisplay: the error message is:java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    java.lang.NullPointerException
    where endDateAndTime is
    // takes in the startDateAndTime as a formatted String (before it is converted into a Date object)
    public String getEndTime(int s, int ID, String stDateAndTime) {
    String end = null;
    gui g = new gui();
    try {
    String sql = "SELECT End FROM wnioutput WHERE Id = " + ID +
    " AND Section = " + s +
    " AND Start = '" + stDateAndTime + "' AND Field = 'Wind50m'";
    ResultSet result = g.queryDatabase(sql);
    if (result.next())
    end = result.getString("End");
    } catch (SQLException sqlex) {
    System.out.println("Error occured in getting endDateAndTime: " + sqlex.toString());
    return end;
    Although this method worked fine before. So the error is in setting the date object in the prepared statement. Anymore suggestions??

  • Prepared statement help

    Hello all!
    I am trying to get this prepared statement to work but am getting an error that I cant understand.
    Basically I have a class file that the ps resides in. I am calling the ps from a jsp.
    Here is the code:
    public void recordUsage(String userid, String ipaddress, String page, String filename)
           String insertStatement = "INSERT INTO usageLog(userId,ipAddress, localTime, page, fileName) VALUES(?,?,?,?,?)";
                try
                {   java.util.Date currentDate=new java.util.Date();//Create a date object for the timestamp
                    java.sql.Timestamp ts=new java.sql.Timestamp(currentDate.getTime());//Create the timestamp from the above date object.
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    objConn = java.sql.DriverManager.getConnection("jdbc:odbc:sensorWeek","","");
                    PreparedStatement ps = objConn.prepareStatement(insertStatement);
                    ps.setString(1, userid);
                    ps.setString(2, ipaddress);
                    ps.setTimestamp(3, ts);
                    ps.setString(4, page);
                    ps.setString(5, filename);
                    ps.executeUpdate();
                    objConn.commit();
                    ps.close();
                    objConn.close();
                    System.out.println("recordusage method called");
                catch (SQLException s)
                    System.err.println("DataBase PROBLEM");
                    s.printStackTrace();
                catch (Exception e)
                        System.err.println("Error in recordUsage method");
                        e.printStackTrace();
    }Here is the error generated:(I hate to dump this on you)
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: sensorPac.methodClass.record(Ljava/lang/String;Ljava/lang/String;)V
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:534)
    root cause
    javax.servlet.ServletException: sensorPac.methodClass.record(Ljava/lang/String;Ljava/lang/String;)V
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
         at org.apache.jsp.download_jsp._jspService(download_jsp.java:93)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:534)
    TIA!!

    And what makes you think that the above code is causing the problem?

  • Error with ExecuteQuery() in prepared statement

    Hello,
    i' m a new one at java. I' m trying to build a web application in jsp and i have a problem in a simple at log in authentication.
    My code is this:
    <html>
    <head>
    <title>Welcome to the online Boat Shop, Inc.</title></head>
    <body>
    <%@ page language ="java" import = "java.io.*, java.lang.*, java.sql.*" %>
    <% try
    String strUsername = request.getParameter("USERNAME");
    String strPassword = request.getParameter("PASSWORD");
    Class.forName ("org.apache.derby.jdbc.ClientDriver");
    Connection myConn = DriverManager.getConnection("jdbc:derby://localhost:1527/boatsdb","tony", "logo");
    String strSQL = "SELECT USERNAME, PASSWORD FROM BOATDB where USERNAME = ? and PASSWORD = ?";
    PreparedStatement stmt = myConn.prepareStatement(strSQL);
    stmt.setString(1, "USERNAME");
    stmt.setString(2, "PASSWORD");
    ResultSet myResult = stmt.executeQuery(strSQL);
    if(myResult.next()){
    out.println("Login Succesful! A record with the given user name and password exists");
    } else {
    out.println("Login Failed. No records exists with the given user name and password");
    myResult.close();
    stmt.close();
    myConn.close();
    } catch(Exception e){
    out.println(e);
    %>
    </body>
    </html>
    The problem is that prepared statement doesn't support executeQuery() method and i can find any solution. The error is this:
    java.sql.SQLException: Method 'executeQuery(String)' not allowed on prepared statement. I already have some data in my database so that it can return results.
    Thank you.
    Edited by: antonis on May 3, 2008 6:13 AM

    thank you, that was the problem. It seems that i have also done mistakes in passing the username and password from the forms to the database for checking, because the message that i get always when i log is that there is no user with this username kai password.
    <form method=GET action=log1.jsp>
    <font size=5> Username <input type=text name="USERNAME" size=20>
              </font>
              <br>
              <font size=5> Password <input type=text name="PASSWORD" size=20>
              </font>
              <br>
              <input type=submit name=action value="Submit">
    </form>
    That's the forms and combined with the code in the fist post should have worked. Any ideas?
    thanks again.

  • Problem in inserting to MS Access using prepared statement

    I am inserting a record in MS Access db and I am using prepared statement. I am encountering an error.... any help I would really appreciate it. So much time figuring out what the problem is....
    ConvertText contxt = new ConvertText();
    String bday = (String)cbYear.getSelectedItem() +
    cbMonth.getItemCount()+(String)cbDay.getSelectedItem();
    try{
    // load MySQL driver
    Class.forName(driver);
    // Setup connection to DBMS
    Connection conn = DriverManager.getConnection(url);
    // Create statement     
    Statement stmt     = conn.createStatement();
    PreparedStatement insertPersons = conn.prepareStatement(
            "INSERT INTO PERSONS VALUES(" +
         "FIRST_NAME               = ?," +
         "LAST_NAME              = ?," +
         "MIDDLE_NAME               = ?," +
         "NICKNAME              = ?," +
         "GENDER              = ?," +
         "MARITALSTATUS           = ?," +
         "AGE                    = ?," +
         "BIRTHDATE                   = ?," +
         "ADDRESS                  = ?," +
         "RES_PHONE_NUMBER        = ?," +
         "OFFICE_PHONE_NUMBER     = ?," +
         "CELL_NUMBER               = ?," +
         "COMPANY_NAME               = ?," +
         "EMAIL_ADDRESS               = ?," +
         "TIMESTAMP               = ?)"
              insertPersons.setString   (1, tfFirstName.getText());
              insertPersons.setString   (2, tfLastName.getText());
              insertPersons.setString   (3, tfMiddleName.getText());
              insertPersons.setString   (4, tfNickName.getText());
              insertPersons.setString   (5, (String)cbGender.getSelectedItem());
              insertPersons.setString   (6, (String)cbMaritalStatus.getSelectedItem());
              insertPersons.setInt      (7, contxt.formatStringToInt(tfAge.getText()));
              insertPersons.setDate     (8, contxt.formatStringToSQLDate(bday));
              insertPersons.setString   (9, tfAddress.getText());
              insertPersons.setString   (10,tfResPhoneNumber.getText());
              insertPersons.setString   (11,tfOffPhoneNumber.getText());
              insertPersons.setString   (12,tfCellNumber.getText());
              insertPersons.setString   (13,tfCompanyName.getText());
              insertPersons.setString   (14,tfEmailAddress.getText());
              insertPersons.setTimestamp(15, new Timestamp(System.currentTimeMillis()));          
              insertPersons.executeUpdate();
              conn.close();          
    JOptionPane.showMessageDialog(null,"Record Inserted!", "INSERT",
                        JOptionPane.INFORMATION_MESSAGE);
    }catch (SQLException ex){
    System.err.println("==> SQLException: ");
    System.out.println("Message:   SQL Exception");
    System.out.println("Message:   " + ex.getMessage ());
    System.out.println("SQLState:  " + ex.getSQLState ());
    System.out.println("ErrorCode: " + ex.getErrorCode ());
    JOptionPane.showMessageDialog(null, ex.getMessage() + ex.toString(),"Error", JOptionPane.INFORMATION_MESSAGE);
    }catch(Exception ex){
    }          ERROR Displayed:
    [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 30. java.sql.SQLException     

    Hi cruzdhel,
    Your SQL looks incorrect to me.
    I am not familiar with that syntax.
    I think it should be like this:
    PreparedStatement insertPersons =
    conn.prepareStatement("INSERT INTO PERSONS (FIRST_NAME," +
                                               "LAST_NAME," +
                                               "MIDDLE_NAME," +
                                               "NICKNAME," +
                                               "GENDER," +
                                               "MARITALSTATUS," +
                                               "AGE," +
                                               "BIRTHDATE," +
                                               "ADDRESS," +
                                               "RES_PHONE_NUMBER," +
                                               "OFFICE_PHONE_NUMBER," +
                                               "CELL_NUMBER," +
                                               "COMPANY_NAME," +
                                               "EMAIL_ADDRESS," +
                                               "TIMESTAMP)" +
    "values (?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?," +
            "?)");Hope this helps.
    Good Luck,
    Avi.

  • Prepared Statement Slow. ~Baffled~. Will the sun rise again?

    HELP! (PANIC), Disaster
    Problem?: Its slow.
    How can you help?: Explain why and make suggestions to fix it.
    NOTES:
    1) there are indices on pd_idnum and pd_nappi_product_id
    2) over 92000 records in the product table
    Code Follows:
    import java.sql.*;
    import java.text.SimpleDateFormat;
    public class DBTest
    static PreparedStatement pstmtNewNappi = null;
    ResultSet rsNappi6=null;
    Connection myConn = null;
    int pd_idnum=0;
    SimpleDateFormat sDateFmt = new SimpleDateFormat("yyyyMMdd");
    SimpleDateFormat sTimeFmt = new SimpleDateFormat("hhmmss");
    * Constructor for DBTest.
    public DBTest()
    super();
    try
    Class.forName("org.gjt.mm.mysql.Driver");
    myConn = DriverManager.getConnection(
    "jdbc:mysql://carl-lin:3306/mxprod", "carl", "lrac1234");
    pstmtNewNappi = myConn.prepareStatement(
    "SELECT pd_idnum FROM product WHERE pd_nappi_prod_id=?");
    catch(ClassNotFoundException cnfe){cnfe.printStackTrace();}
    catch(SQLException sqle){sqle.printStackTrace();}
    public boolean isNewNappi(String nappi) throws SQLException
    if(nappi != null)
    pstmtNewNappi.setInt(1, Integer.parseInt(nappi));
    System.out.println("before execute"
    +new java.util.Date().getTime());
    // This single line of code takes 2 seconds!! Why?
    rsNappi6 = pstmtNewNappi.executeQuery();
    System.out.println("after execute"
    +new java.util.Date().getTime());
    if(rsNappi6.next())
    //if im in here the nappi is not new
    pd_idnum = Integer.parseInt(rsNappi6.getString("pd_idnum"), 10);
    return false;
    return true;
    public static void main(String[] args)
    try
    DBTest dbt = new DBTest();
    boolean yes = dbt.isNewNappi("43");
    System.out.println("yes: " + yes);
    catch(SQLException sqle)
    sqle.printStackTrace();
    Maybe PreparedStatements are only fast for inserts(Forgive me for guesing)
    Any help would be greatly appreciated

    Oh that came back like lighting allright but i got my hands on some more code here that (if my reasoning is correct) suggest that I'm using the prepared statement in the wrong way, but I can still not figure out why it is wrong. The DB is not the problem and I think the code below and its output is testament to that. Now that i've got fast code, I'm still not content because I still cant see what is wrong with the original code. In order for me to keep my sanity as a programmer I HAVE to know --WHAT IS WRONG aaaargh
    Thanx for the help so far
    Dewet
    optimal code follows:
    import java.sql.*;
    public class Fix
    public static void main(String[] args)
    ResultSet prodSet = null;
    String nappi = null;
    String sql = null;
    try
    Class.forName("org.gjt.mm.mysql.Driver");
    Connection myConn = DriverManager.getConnection("jdbc:mysql://carl:3306/mxprod?user=carl&password=lrac1234");
    sql = "select pd_prod_name, pd_prod_name_mk from product where pd_nappi_prod_id = ?";
    PreparedStatement stmt2 = myConn.prepareStatement(sql);
    nappi = "43";
    for (int i= 0; i < 10; i++)
                   System.out.println(i);
    System.out.println(new java.util.Date().getTime());
    stmt2.setString(1, nappi); // Nappi
    prodSet = stmt2.executeQuery();
    if(prodSet.next())
    {*nappi found*/}     
    System.out.println(new java.util.Date().getTime());
    if (stmt2 != null) stmt2.close();
    myConn.close();
    catch( Exception e )
    e.printStackTrace();
    output:
    0
    1055320536664
    1055320536694
    1
    1055320536694
    1055320536694
    2
    1055320536704
    1055320536704
    3
    1055320536704
    1055320536714
    4
    1055320536714
    1055320536714
    5
    1055320536714
    1055320536714
    6
    1055320536724
    1055320536724
    7
    1055320536724
    1055320536724
    8
    1055320536734
    1055320536734
    9
    1055320536744
    1055320536744

  • Prepared statement not releasing from access db

    Hello all,
    I have several prepared statements like the following:
    public void storeUpdate(String userId,String ws,String wm,String wl,String wx,String wxx,String bs,String bm,String bl,String bx,String bxx, String tq, String tp,Timestamp ts)
         String updatePurchase = "UPDATE store SET smallWhite=?,medWhite=?,lrgWhite=?,xlrgWhite=?,xxlrgWhite=?,smallBlue=?,medBlue=?,lrgBlue=?,xlrgBlue=?,xxlrgBlue=?,totalQty=?,totalPrice=?,ot=? WHERE playerNo='"+userId+"'";
         try{
             Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
             objConn = java.sql.DriverManager.getConnection("jdbc:odbc:myDB","","");
             PreparedStatement ps = objConn.prepareStatement(updatePurchase);
             ps.setString(1, ws);
             ps.setString(2, wm);
             ps.setString(3, wl);
             ps.setString(4, wx);
             ps.setString(5, wxx);
             ps.setString(6, bs);
             ps.setString(7, bm);
             ps.setString(8, bl);
             ps.setString(9, bx);
             ps.setString(10, bxx);
             ps.setString(11, tq);
             ps.setString(12, tp);
             ps.setTimestamp(13,ts);
             ps.executeUpdate();
             ps.close();
             objConn.close();
                catch (SQLException s)
                    System.err.println("DataBase PROBLEM");
                    s.printStackTrace();
                catch (Exception e)
                        System.err.println("Error in updateStore method");
                        e.printStackTrace();
    } The prepared stmts seem to be "hanging on to" the access(dont laugh)table that the prepared stmt just updated. The reason I know this is because when I try to look at the table in access's design view I get a message saying:
    "Microsoft access
    You cant open the table 'store' for modification.
    A query or form bound to the table is open, you may not have permission to open this table in design view, or another user has the table open.
    If you have opened a query or form bound to this table, close it, and then try again to open the table in design view."
    The only way to open the table in design view is to shut down tomcat and restart.
    Should I be worried about this?
    Am i forgetting to close something in my ps?
    TIA!!

    I use PreparedStatement all the time with Access and never have a problem. The only thing I noticed about your code is that if an exception gets thrown in your method, the close statements won't get executed. This might leave the tables locked. You might want to try moving the close statements into a finally block. That way your statement and connection will get closed if an exception gets thrown or not.

  • Update record with prepared statement

    Below is my prepared statement that I cannot get to work, I keep getting a stack trace error that I cannot understand.
    //methodClass.class
    public void updateUser(String pwd,String userid,Timestamp pwdtime)
            String updateStatement = "update userSec set password=(?), passwordChanged=(?) where userId =(?)";
                try
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    objConn = java.sql.DriverManager.getConnection("jdbc:odbc:sensorWeek","","");
                    PreparedStatement ps = objConn.prepareStatement(updateStatement);
                    ps.setString(1, pwd);
                    ps.setString(2, "YES");
                    ps.setString(3, userid);
                    ps.setTimestamp(4,pwdtime);
                    ps.executeUpdate();
                    ps.close();
                    objConn.close();
                catch (SQLException s)
                    System.err.println("SQL Error in updateUser Prepared Statement");
                    s.printStackTrace();
                catch (Exception e)
                    System.err.println("Error in updateUser Prepared Statement");
                    e.printStackTrace();
      }I call the ps from the jsp like so:
    java.util.Date currentDate = new java.util.Date();
    java.sql.Timestamp ts = new java.sql.Timestamp(currentDate.getTime());
    methodClass mc = new methodClass();
    mc.updateUser(request.getParameter("pwd3").toString(),request.getParameter("userId").toString(),ts);Here is the stack trace:
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    org.apache.jasper.JasperException: sensorPac.methodClass.updateUser(Ljava/lang/String;Ljava/lang/String;Ljava/sql/Timestamp;)V
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:254)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:430)
         at org.apache.jsp.checkPwd_jsp._jspService(checkPwd_jsp.java:69)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:534)
    root cause
    javax.servlet.ServletException: sensorPac.methodClass.updateUser(Ljava/lang/String;Ljava/lang/String;Ljava/sql/Timestamp;)V
         at org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:536)
         at org.apache.jsp.changePwd_jsp._jspService(changePwd_jsp.java:295)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
         at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:432)
         at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:356)
         at org.apache.jasper.runtime.PageContextImpl.forward(PageContextImpl.java:430)
         at org.apache.jsp.checkPwd_jsp._jspService(checkPwd_jsp.java:69)
         at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.CertificatesValve.invoke(CertificatesValve.java:246)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2416)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:171)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:172)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:641)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:174)
         at org.apache.catalina.core.StandardPipeline$StandardPipelineValveContext.invokeNext(StandardPipeline.java:643)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:480)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:995)
         at org.apache.coyote.tomcat4.CoyoteAdapter.service(CoyoteAdapter.java:223)
         at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:601)
         at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:392)
         at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:565)
         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:619)
         at java.lang.Thread.run(Thread.java:534)
    Any Ideas?
    Thanks!!

    Sorry, I mistyped the statement, here is the corrected statement:
    public void updateUser(String pwd,String userid,Timestamp pwdtime)
            String updateStatement = "update userSec set password=(?), passwordChanged=(?),passwordChTime = (?)  where userId =(?)";
                try
                    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                    objConn = java.sql.DriverManager.getConnection("jdbc:odbc:sensorWeek","","");
                    PreparedStatement ps = objConn.prepareStatement(updateStatement);
                    ps.setString(1, pwd);
                    ps.setString(2, "YES");
                    ps.setTimestamp(3,pwdtime);
                    ps.setString(4, userid);
                    ps.executeUpdate();
                    ps.close();
                    objConn.close();
                catch (SQLException s)
                    System.err.println("SQL Error in updateUser Prepared Statement");
                    s.printStackTrace();
                catch (Exception e)
                    System.err.println("Error in updateUser Prepared Statement");
                    e.printStackTrace();
      }

  • Problem in prepared Statement

    hi,
    i have used following prepared Statement for the update in database.
    Can any one tell me that,How can i use date in following method.
    I have 4 field for date as given below:(BOLD shown)
    I have used String in that place.
    It is not working.
    PreparedStatement pstatement = conn.prepareStatement(
    "UPDATE sec_mast SET catg_code=?, vou_no=?, vou_date=?, vou_amt=?, due_date1=?, due_date2=?, mat_date=? where sec_no=? ");
    pstatement.setInt(1,Integer.parseInt(request.getParameter("catg_code")));
    pstatement.setString(2,request.getParameter("vou_no"));
    pstatement.setString(3,request.getParameter("vou_date"));
    pstatement.setInt(4,Integer.parseInt(request.getParameter("vou_amt")));
    pstatement.setString(5,request.getParameter("due_date1"));
    pstatement.setString(6,request.getParameter("due_date2"));
    pstatement.setString(7,request.getParameter("mat_date"));
    pstatement.setInt(8,Integer.parseInt(request.getParameter("sec_no")));
    int rowCount = pstatement.executeUpdate();
    conn.setAutoCommit(false);
    conn.setAutoCommit(true);
    plz help me

    thanx for u r reply.
    MY whole code is shown as below:
    This page is for the updating the values in database..
    <html>
    <body>
    <table>
    <tr>
    <td>
    <%@ page import="javax.servlet.*" %>
    <%@ page import="javax.servlet.http.*" %>
    <%@ page language="java" import="java.sql.*" %>
    <%
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection conn=DriverManager.getConnection("jdbc:odbc:pf","scott","ttlscott");
    System.out.println("got connection");
    %>
    <%
    String action = request.getParameter("action");
    // Check if an update is requested
    if (action != null && action.equals("update")) {
    conn.setAutoCommit(false);
    PreparedStatement pstatement = conn.prepareStatement(
    "UPDATE sec_mast SET sec_no=? , catg_code=?, face_val=?, pur_val=?, int_paid=?, int_recd=?, brkr=?, vou_no=?, vou_date=?, vou_amt=?, due_date1=?, due_date2=?, lf_no=?, mat_date=? where tot_val=? ");
    pstatement.setInt(1,Integer.parseInt(request.getParameter("sec_no")));
    pstatement.setInt(2,Integer.parseInt(request.getParameter("catg_code")));
    pstatement.setInt(3,Integer.parseInt(request.getParameter("face_val")));
    pstatement.setInt(4,Integer.parseInt(request.getParameter("pur_val")));
    pstatement.setInt(5,Integer.parseInt(request.getParameter("int_paid")));
    pstatement.setInt(6,Integer.parseInt(request.getParameter("int_recd")));
    pstatement.setInt(7,Integer.parseInt(request.getParameter("brkr")));
    pstatement.setString(8,request.getParameter("vou_no"));
    pstatement.setString(9,request.getParameter("vou_date"));
    pstatement.setInt(10,Integer.parseInt(request.getParameter("vou_amt")));
    pstatement.setString(11,request.getParameter("due_date1"));
    pstatement.setString(12,request.getParameter("due_date2"));
    pstatement.setString(13,request.getParameter("lf_no"));
    pstatement.setString(14,request.getParameter("mat_date"));
    pstatement.setInt(15,Integer.parseInt(request.getParameter("tot_val")));
    int rowCount = pstatement.executeUpdate();
    conn.setAutoCommit(false);
    conn.setAutoCommit(true);
    %>
    <%
    // Create the statement
    Statement statement = conn.createStatement();
    ResultSet rs = statement.executeQuery
    ("SELECT * from sec_mast ");
    %>
    <%
    // Iterate over the ResultSet
    while ( rs.next() ) {
    %>
    <tr>
    <form action="security_update.jsp" method="get">
    <input type="hidden" value="update" name="action">
    <td><input value="<%= rs.getInt("sec_no") %>" name="sec_no"></td>
    <td><input value="<%= rs.getInt("catg_code") %>" name="catg_code"></td>
    <td><input value="<%= rs.getInt("face_val") %>" name="face_val"></td>
    <td><input value="<%= rs.getInt("pur_val") %>" name="pur_val"></td>
    <td><input value="<%= rs.getInt("int_paid") %>" name="int_paid"></td>
    <td><input value="<%= rs.getInt("int_recd") %>" name="int_recd"></td>
    <td><input value="<%= rs.getInt("brkr") %>" name="brkr"></td>
    <td><input value="<%= rs.getInt("tot_val") %>" name="tot_val"></td>
    <td><input value="<%= rs.getString("vou_no") %>" name="vou_no"></td>
    <td><input value="<%= rs.getDate("vou_date") %>" name="vou_date"></td>
    <td><input value="<%= rs.getInt("vou_amt") %>" name="vou_amt"></td>
    <td><input value="<%= rs.getDate("due_date1") %>" name="due_date1"></td>
    <td><input value="<%= rs.getDate("due_date2") %>" name="due_date2"></td>
    <td><input value="<%= rs.getString("lf_no") %>" name="lf_no"></td>
    <td><input value="<%= rs.getDate("mat_date") %>" name="mat_date"></td>
    <td><input type="submit" value="Update"></td>
    </form>
    </tr>
    <%
    %>
    </table>
    <%
    // Close the ResultSet
    rs.close();
    // Close the Statement
    statement.close();
    // Close the Connection
    conn.close();
    } catch (SQLException sqle) {
    out.println(sqle.getMessage());
    } catch (Exception e) {
    out.println(e.getMessage());
    %>
    </td>
    </tr>
    </body>
    </html>

  • Problem with Prepared Statement & MS Access

    Hi
    I have tried to find some info about this but can't see anything specific to what I think the problem may be. Hopefully someone can point me in the right direction.I am trying to get information out of an MS Access database using a Prepared Statement but I am getting strange results.
    When I run the query in the database it gives me the correct totals (�51) for 4 records. When I run the Prepared Statement ,I get 81. Has it got anything to do with the data type I am using( sorry if this is a really basic question). here is my code- the connection etc is elsewhere.
    private void getReportMoneyTotal() throws SQLException
              Calendar todayTotal =Calendar.getInstance() ;
               SimpleDateFormat reportDateFormat = new SimpleDateFormat("dd MM yyyy");
              PreparedStatement preparedT =context.getConnection().prepareStatement(
                   "SELECT Sum(tblSession.Fee) AS Total, Count(tblBooking.BookingID) AS CountOfBookingID FROM tblSession INNER JOIN "+
                   "(tblBooking INNER JOIN tblCustomer_Booking ON tblBooking.BookingID = tblCustomer_Booking.BookingID) ON tblSession.SessionID = tblBooking.SessionID "+
                   "WHERE (((tblBooking.EventDate)>DateAdd('m',-1,#"+reportDateFormat.format(todayTotal.getTime())+"#)) AND ((tblSession.Session)='Morning' Or (tblSession.Session)='Evening')) OR (((tblSession.Session)='Afternoon') AND ((tblBooking.Extension)=Yes))"
              ResultSet resultTotal =preparedT.executeQuery();
              resultTotal.next();
              Double total =resultTotal.getDouble("Total");
              Locale locale = new Locale("GBP");
            NumberFormat gbpFormat = NumberFormat.getCurrencyInstance(locale);
              System.out.println(gbpFormat.format(total));
              preparedT.close();
         }I do realise that my code probably isn't very elegant but I'm only learning!

    Hi Matt--
    I am not clear if you are saving the url with the # # around
    the text or if
    the
    data already contains the # marks.
    When you insert a link, you want to make sure you insert is
    insert into table ( link1) values ( <cfqueryparam
    cfsqltype="cf_sql_varchar"
    value='#linkvaluehere#'> )
    remember to
    1) enclose your data's value inside quotes (some databases
    are picky about
    single v. double quotes).
    2) if it IS in quotes, swap doubles for singles and see if
    that helps.
    3) make sure your data being saved is NOT double hashed like
    '##linkvalueher##'. Double ##'s tell
    Coldfusion not to treat it as a variable.
    hope his helps,
    tami
    "Mattastic" <[email protected]> wrote in
    message
    news:f9c7h0$8ub$[email protected]..
    | Hi Folks,
    |
    | I'm storing a link in a nvarchar field in SQL server,
    www.foo.co.uk, it
    looks
    | and works fine in SQL server. Problem occurs when I setup
    an ADP in Access
    and
    | insert links. Certain links have a hash symbol around them.
    so
    |
    http://www.foo.co.uk, would be #
    http://www.foo.co.uk# which is
    causing
    problems.
    |
    | Can anyone tell me why this is happening? and how to stop
    it?
    |
    | Thankyou
    |

  • How to use prepared statement - For Everyone Help

    public String count()
    int count = 0;
    String fetchsize = "";
    try
    Connection conn = getOADBTransaction().getJdbcConnection();
    Statement statement = conn.createStatement();
    String Query = "select count(*) count from fnd_lookups where lookup_type like 'SAPE_BILL_TO_SHIP_TO_UPDATE'";
    ResultSet resultset = statement.executeQuery(Query);
    while (resultset.next())
    count = (int)resultset.getInt("count");
    fetchsize = ""+count;
    catch(Exception e)
    return fetchsize;
    }

    Hi,
    we can use prepare statement in Co....
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    try
    PreparedStatement prpdStmt1 = am.getOADBTransaction().getJdbcConnection().prepareStatement("select full_name from per_all_people_f where person_id='"+empid+"' ");
    ResultSet rs=prpdStmt1.executeQuery(); //Cursor fetch row
    while(rs.next())
    empname=rs.getString(1);
    catch(Exception e)
    System.out.println("Exception is"+e.getMessage());
    t1.setValue(pageContext,empname);
    Thanks
    nani

Maybe you are looking for

  • ARD 3.0 - Connecting to Windows XP Pro PC

    I have tried my best to connect to my windows xp machine however can never get it to work. I have tried to connect via i.p (i assume u do this by running ipconfig) The Status of the Windows PC is always offline. I do have remote turned on in My Compu

  • Bring back Firefox 3 why fix what isn't broken? I hate this firefox 4

    This latest upgrade is the pits, I can't stand all the tabs and the layout. Just let me have my old firefox back, those who want this can have it. In other words I prefer to use IE and I have NOT used it in years, I hate it because of it being micros

  • Calling WDA from Microsoft .

    Hi Every body , I want to call a WDA applcation from from Non- SAP portal . I want to call a WDA applcation from microsoft portal . Is it possible to call WDA in internet not in intranet . Thanks in advance , Sethu

  • Setting the PO output type

    Hi All, I have requirement where I need to set the output type of PO to XML always. Has anybody done this before? Please let me know. Regards Amitabh

  • Selective footage not rendering!!

    Hi, I have a 5 min video and when rendering, it displays a slow preview as it renders, everything looks fine there, but when I look at the rendered .avi, there are two layers which are not rendering, even though they appear in the preview and everyth