ArrayIndexOutOfBoundsException when setting a date in a prepared statement

Hi,
was wondering if anyone could help. I have a prepared statement, with two "variables" in it. I need to set the first of these to a string (using setString(1, "string)
and the second to a date, using setDate(2, SQLDate)
My SQL date is a valid date ass I've run a debugger and checked, but everytime setDate is called an Array Out Of Bound Exception is thrown. Can anyone shed any light on this as I'm rather confused as to why this is happening!
Thanks in advance

I havent got a small runnable example to hand, but taking an excert from my code I have:
for (int i = 0; i < this.columnNames.size();i++)
singleDateEventFlagSingleArea.setString(1, newAreaName);
singleDateEventFlagSingleArea.setDate(2, Date.valueOf((String) this.columnNames.get(i)));
eventFlagsResult = singleDateEventFlagSingleArea.executeQuery()
}newAreaName is a argument passed to the method. columnNames is a vector of dates/strings, which I parse back into a date to pass to the setDate method
Where the value of the date in the statement is changed to a preset value each iteration.
The exception stack I'm getting is:
exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1
     at oracle.jdbc.dbaccess.DBDataSetImpl._getDBItem(DBDataSetImpl.java:378)
     at oracle.jdbc.dbaccess.DBDataSetImpl._createOrGetDBItem(DBDataSetImpl.java:781)
     at oracle.jdbc.dbaccess.DBDataSetImpl.setBytesBindItem(DBDataSetImpl.java:2399)
     at oracle.jdbc.driver.OraclePreparedStatement.setItem(OraclePreparedStatement.java:1134)
     at oracle.jdbc.driver.OraclePreparedStatement.setDate(OraclePreparedStatement.java:2223)
     at treeTableVersion2.TreeTable.updateValuesSingleDateSingleArea(TreeTable.java:393)
     at treeTableVersion2.TestWindow.actionPerformed(TestWindow.java:394)
     at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1849)
     at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2169)
     at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
     at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
     at java.awt.Component.processMouseEvent(Component.java:5488)
     at javax.swing.JComponent.processMouseEvent(JComponent.java:3126)
     at java.awt.Component.processEvent(Component.java:5253)
     at java.awt.Container.processEvent(Container.java:1966)
     at java.awt.Component.dispatchEventImpl(Component.java:3955)
     at java.awt.Container.dispatchEventImpl(Container.java:2024)
     at java.awt.Component.dispatchEvent(Component.java:3803)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
     at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
     at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
     at java.awt.Container.dispatchEventImpl(Container.java:2010)
     at java.awt.Window.dispatchEventImpl(Window.java:1774)
     at java.awt.Component.dispatchEvent(Component.java:3803)
     at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
     at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
     at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)Although I think a lot of that is because the process is called by a button press.
The sql statement thats causing the problem is:
select h.areaname,
       e.code,
       e.descript,
       ec.date_raised,
       ec.date_progressing,
       ec.date_completed
  from hareas h, evt_type e, evt_core ec
where h.areaname = ?
   and e.evt_type_id = ec.evt_type_id
   and (h.nblink = ec.area1_nblink or h.nblink = ec.area2_nblink)
   and ec.date_raised = ?
group by h.areaname,
          e.code,
          e.descript,
          ec.date_raised,
          ec.date_progressing,
          ec.date_completed
order by h.areanameThanks for your help

Similar Messages

  • ArrayIndexOutOfBoundsException when setting visibility to the caret

    Hi all,
    I made a JTextPane and run into some problems. I get an ArrayIndexOutOfBoundsException when I'm setting it's caret visibility to true and false:
            JEditorPane textPane = new JTextPane;
            // add the textPane to a frame's ContentPane   
         public void test() {
              for(int i = 0; i<100;  i++) {
                   testVisibility(true);
                   testVisibility(false);
         private void testVisibility(boolean b) {
              // This is were the exception will be thrown if the text pane is visible
              // when making these calls.
              textPane.setEditable(b);
              textPane.getCaret().setVisible(b);
         }The snippet throws an ArrayIndexOutOfBoundsException:
    java.lang.ArrayIndexOutOfBoundsException
         at java.lang.System.arraycopy(Native Method)
         at javax.swing.text.BoxView.updateLayoutArray(BoxView.java:197)
         at javax.swing.text.BoxView.replace(BoxView.java:168)
         at javax.swing.text.View.append(View.java:432)
         at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:412)
         at javax.swing.text.FlowView.layout(FlowView.java:184)
         at javax.swing.text.BoxView.setSize(BoxView.java:379)
         at javax.swing.text.BoxView.updateChildSizes(BoxView.java:348)
         at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:330)
         at javax.swing.text.BoxView.layout(BoxView.java:682)
         at javax.swing.text.BoxView.setSize(BoxView.java:379)
         at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1618)
         at javax.swing.plaf.basic.BasicTextUI.modelToView(BasicTextUI.java:946)
         at javax.swing.text.DefaultCaret.setVisible(DefaultCaret.java:952)
         at org.seba.JTextPaneTest.testVisibility(JTextPaneTest.java:38)
         at org.seba.JTextPaneTest.test(JTextPaneTest.java:29)
         at org.seba.JTextPaneTest.main(JTextPaneTest.java:24)

    import javax.swing.JEditorPane;
    import javax.swing.JFrame;
    import javax.swing.JTextPane;
    public class JTextPaneTest {
         JFrame mainFrame;
         JEditorPane textPanel;
         public JTextPaneTest() {
              textPanel = new JTextPane();
            mainFrame = new JFrame("Test Frame.");
            mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            mainFrame.setSize(640, 480);
              mainFrame.getContentPane().add(textPanel);
              mainFrame.setVisible(true);
         public static void main(String[] args) {
              JTextPaneTest textPaneTest = new JTextPaneTest();
              textPaneTest.test();
         public void test() {
              for(int i = 0; i<100;  i++) {
                   testVisibility(false);
                   testVisibility(true);
         private void testVisibility(boolean b) {
              // This is were the exception will be thrown if the text panel is visible
              // when making these calls.
              textPanel.setEditable(b);
              textPanel.getCaret().setVisible(b);
    }I hope it's ok. You'll have to use Java 5 (1.5.0.11) to compile and run it.
    I run into the problem when I made the text pane not editable and the caret was still visible. I needed the caret to hide away too when making the text pane not editable. If I use the setEnabled(boolean) to disable the text pane, all the text is made grey.(I know that there are some methods to make this not happen). I just don't know why this simple test is not working as I would expect.

  • 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??

  • When setting Time & Date Laptop Freeze

    Hi
    When I set my correct date & time with
    date 041118002006
    my laptop freez, and i only can reset.
    What is this?

    init wrote:
    is your current time behind or in the future?
    In the Bios the time is normaly, In X 2 houers in future
    this may because a wrong timezone/bios time combination was set in rc.conf. if you have a m$-linux dual-boot, set
    HARDWARECLOCK="UTC"
    in any other case use localtime. pay attention with timezone as it is case sensitive and might confuse linux if set incorrectly.
    setting time into the past normally is not a problem for linux, except that application timers may be confused. for example flashplugin seriously doesn't like it when you set the time before it was started.

  • Patch Policies not applying when set to Date Specific

    I have been trying to use patch policies for a while but can't seem to get
    them working very well. In 'Patch Policy Enforcement Settings' I have set
    a schedule using 'Date Specific' and 'Process immediately'. If I check the
    patch status policy I see 100 targeted/ 12 Effective/ 0 Not Effective/ 88
    Pending. The 88 never move from pending even though almost all of them need
    the required patches. If I set the schedule to Recurring and 'When a device
    is refreshed' it basically tries to install the patches on every refresh
    cycle even though the device no longer requires the patches. This happens
    on every device targeted by the policy.
    Digging into the actually bundle that gets created I can see in the install
    actions the Install Frequency is set to 'Install always' which may explain
    why it runs through each patch every refresh when it is set to install on
    refresh.
    The documentation on this new feature doesn't go into much detail on how
    everything actually works. I would guess the correct functionality would be
    once a policy is enforced on a machine it would no longer try to keep
    installing the same patches from the policy since they are not needed.
    Using the Enforcement by 'Date Specific' seems to be broke also.
    Jim Koerner
    Server - ZCM 11.3.1FTF1 and Internal Database on Win2008R2x64
    Clients - ZCM 11.3.1FTF1 on Win7SP1x64

    Originally Posted by Jim Koerner
    Sounds just like it. Missed when I was browsing the knowledge base. doing
    some more detailed searching I fount this in readme for 11.3.1 "Defects
    addressed 848442 Process immediately if device unable to execute on
    schedule" option doesn't work of Patch Policy Enforcement Settings. In my
    case this is not fixed and I am at 11.3.1FTF1
    I will have to put in a SR and see if anything has been done with it since.
    Jim
    "thsundel" wrote in message news:[email protected]...
    Jim Koerner;2337983 Wrote:
    > I have been trying to use patch policies for a while but can't seem to
    > get
    > them working very well. In 'Patch Policy Enforcement Settings' I have
    > set
    > a schedule using 'Date Specific' and 'Process immediately'. If I check
    > the
    > patch status policy I see 100 targeted/ 12 Effective/ 0 Not Effective/
    > 88
    > Pending. The 88 never move from pending even though almost all of them
    > need
    > the required patches. If I set the schedule to Recurring and 'When a
    > device
    > is refreshed' it basically tries to install the patches on every refresh
    > cycle even though the device no longer requires the patches. This
    > happens
    > on every device targeted by the policy.
    >
    > Digging into the actually bundle that gets created I can see in the
    > install
    > actions the Install Frequency is set to 'Install always' which may
    > explain
    > why it runs through each patch every refresh when it is set to install
    > on
    > refresh.
    >
    > The documentation on this new feature doesn't go into much detail on how
    > everything actually works. I would guess the correct functionality
    > would be
    > once a policy is enforced on a machine it would no longer try to keep
    > installing the same patches from the policy since they are not needed.
    > Using the Enforcement by 'Date Specific' seems to be broke also.
    >
    > Jim Koerner
    > Server - ZCM 11.3.1FTF1 and Internal Database on Win2008R2x64
    > Clients - ZCM 11.3.1FTF1 on Win7SP1x64
    Could be this: http://www.novell.com/support/kb/doc.php?id=7015217
    Thomas
    thsundel
    thsundel's Profile: https://forums.novell.com/member.php?userid=128
    View this thread: https://forums.novell.com/showthread.php?t=480214
    Yes, please do open a SR if you can..
    Thomas

  • How to avoid exception when setting a date in an Edit control?

    I'm have made a Coded UI Test with VS 2012 for a web application of a colleague.
    In that web application is a table with some entry fields of type Edit.
    In one of these fields (called "DatumAb") i can enter a date in format "dd.mm.yyyy" (day, month and year).
    Coded UI Test identifies the control by the name "von (tt.mm.jjjj)", which is in fact just a placeholder.
    When i replay my recording i get an exception which says, that either the control is not ready or not valid.
    Next i have called the DrawHighlight method for that control.
    While the replay i can see the blue frame, so the control is accessible.
    Can anybody tell me, what's going wrong?
    Here an excerpt from the HTML-Code of the web application with the date field:
    <table class="table table-hover table-bordered table-condensed table-well table-responsive">
      <thead>
        <tr>
          <th class="ng-scope" translate="global.datum.Von">von</th>
        </tr>
      </thead>
      <tbody>
        <!-- ngRepeat: vb in vm.formData.Vorbeschaeftigungen -->
        <tr class="ng-scope" ng-repeat="vb in vm.formData.Vorbeschaeftigungen">
          <td>
            <input value="11.02.2015" rm-date-input="" ng-model="vb.DatumAb" class="form-control ng-pristine ng-untouched ng-valid ng-valid-rm-date-input ng-valid-rm-date-input-format
    ng-valid-rm-date-input-day ng-valid-rm-date-input-month ng-valid-rm-date-input-year" placeholder="von (tt.mm.jjjj)" type="text">
          </td>
    And at last the exception message.
    Sorry - only in german.
    Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException wurde nicht von Benutzercode behandelt.
      HResult=-268111872
      Message=Das Steuerelement ist nicht verfügbar oder nicht gültig. Weitere Details:
    TechnologyName:  "MSAA"
    Name:  "von (tt.mm.jjjj)"
    ControlType:  "Edit"
      Source=Microsoft.VisualStudio.TestTools.UITesting
      BasicMessage=Das Steuerelement ist nicht verfügbar oder nicht gültig.
      StackTrace:
           bei Microsoft.VisualStudio.TestTools.UITesting.Playback.AddUITestControlDescriptionToException(SystemException exception, IPlaybackContext context)
           bei Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, IPlaybackContext context)
           bei Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String actionName, UITestControl uiControl)
           bei Microsoft.VisualStudio.TestTools.UITesting.Playback.MapAndThrowException(SystemException exception, String actionName, Object parameterValue, UITestControl uiControl)
           bei Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyValue(String propertyName, Object propertyValue)
           bei Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyPrivate(String propertyName, Object value)
           bei Microsoft.VisualStudio.TestTools.UITesting.UITestControl.<>c__DisplayClass14.<SetProperty>b__13()
           bei Microsoft.VisualStudio.TestTools.UITesting.CodedUITestMethodInvoker.InvokeMethod[T](Func`1 function, UITestControl control, Boolean firePlaybackErrorEvent, Boolean logAsAction)
           bei Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetProperty(String propertyName, Object value)
           bei Microsoft.VisualStudio.TestTools.UITesting.WinControls.WinEdit.set_Text(String value)
           bei TestMitVorbeschaeftigungen.UIMap.DatumVon() in c:\CodedUiTests\Tests mit Webanwendung\TestMitVorbeschaeftigungen\TestMitVorbeschaeftigungen\UIMap.Designer.cs:Zeile 92.
           bei TestMitVorbeschaeftigungen.CodedUITest1.CodedUITestMethod1() in c:\CodedUiTests\Tests mit Webanwendung\TestMitVorbeschaeftigungen\TestMitVorbeschaeftigungen\CodedUITest1.cs:Zeile 37.
      InnerException: Microsoft.VisualStudio.TestTools.UITest.Extension.UITestControlNotAvailableException
           HResult=-268111872
           Message=Das Steuerelement ist nicht verfügbar oder nicht gültig.
           Source=Microsoft.VisualStudio.TestTools.UITest.Extension.Msaa
           BasicMessage=Das Steuerelement ist nicht verfügbar oder nicht gültig.
           StackTrace:
                bei Microsoft.VisualStudio.TestTools.UITest.Extension.Msaa.MsaaUtility.MapAndThrowException(SystemException e, Boolean throwNotSupported)
                bei Microsoft.VisualStudio.TestTools.UITest.Extension.Msaa.AccWrapper.set_Value(String value)
                bei Microsoft.VisualStudio.TestTools.UITest.Extension.Msaa.MsaaElement.set_Value(String value)
                bei Microsoft.VisualStudio.TestTools.UITesting.WinPropertyProvider.SetValueInEditableControl(UITestControl editControl, String propertyValue)
                bei Microsoft.VisualStudio.TestTools.UITesting.WinPropertyProvider.SetEditProperty(String propertyName, Object value)
                bei Microsoft.VisualStudio.TestTools.UITesting.WinPropertyProvider.SetPropertyValue(UITestControl uiControl, String propertyName, Object value)
                bei Microsoft.VisualStudio.TestTools.UITesting.UITestPropertyProvider.SetPropertyValueWrapper(UITestControl uiControl, String propertyName, Object value)
                bei Microsoft.VisualStudio.TestTools.UITesting.UITestControl.SetPropertyValue(String propertyName, Object propertyValue)
           InnerException: System.NotImplementedException
                HResult=-2147467263
                Message=Die Methode oder der Vorgang ist nicht implementiert.
                Source=Accessibility
                StackTrace:
                     bei Accessibility.IAccessible.set_accValue(Object varChild, String pszValue)
                     bei Microsoft.VisualStudio.TestTools.UITest.Extension.Msaa.AccWrapper.set_Value(String value)
                InnerException:

    Hi Patrick Pirzer,
    >>That either the control is not ready or not valid.
    Next i have called the DrawHighlight method for that control.
    My suggestion is that you would check whether this control is really existing when playback actions run on this control. Or add a wait event would be better.
    http://blogs.msdn.com/b/gautamg/archive/2010/02/12/how-to-make-playback-wait-for-certain-event.aspx
    Reference:
    http://stackoverflow.com/questions/11737254/codedui-test-not-waiting-for-control-to-exist
    Best Regards,
    Jack
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Query slow when executing using prepared statement compared to sqlDeveloper

    Oracle version is 10.2.0.1.0.
    I have got a query which when submitted from java code using prepared statement and parameter substitutions, takes more than 20 seconds to give results.
    I can see this SELECT sql sitting there when I run Monitor Sessions through sqlDeveloper, with its wait time increasing and then finally getting through. During that time no other SQLs are waiting.
    DURING THAT TIME then I am able to run the same query (with values included) multiple times using sqlDeveloper, and it gives results in no time.
    Sqldeveloper connects using thin client using lib provided by oracle in windows.
    Java code runs from linux and uses the thin client using lib provided by oracle in linux.
    Both are hitting the same DB running on a separate Linux machine.
    What could be the cause of this problem?
    What db parameters, queries should I run to identify the bottleneck?
    Edited by: user10390517 on Jun 14, 2010 3:06 AM

    Hi Rob,
    at least you should see some differences in the statistics for the different child cursor (the one for the execution in the application should show at least a higher value for ELAPSED_TIME). I would use something like the following query to check the information for the child cursors:
    select sql_id
         , PLAN_HASH_VALUE
         , CHILD_NUMBER
         , EXECUTIONS
         , ELAPSED_TIME
         , USER_IO_WAIT_TIME
         , CONCURRENCY_WAIT_TIME
         , DISK_READS
         , BUFFER_GETS
         , ROWS_PROCESSED
      from v$sql
    where sql_id = your_sql_idRegards
    Martin

  • Required Prepared Statement help

    Consider the following query
    select col2, col3
    from table1
    where col1 = ?
    I can set the bindings for the prepared statement as pStmt.setString(1, value);
    but sometimes I need all the rows in the table therefore the query would be like
    select col2, col3
    from table1
    where col1 = col1
    I would like to set the first query's bindings for the prepared statement to execute like the second one.
    Please do not ask me to create two different queries. I know it is possible to do it and I would appreciate if you can guide me as to how to set the bindings. Thanks,

    Adam Martin wrote:
    Sorry, you cannot treat a bind variable like a bind some of the time and literal SQL text the other part of the time.
    How about something like this:
    select col2, col3
    from table1
    where col1 between ? and ?When you want a specific value, you can say "between 23 and 23" and when you want all values, you can put extremes in like "between -999999 and 999999" so that all rows a returned.
    This is not to say that this is a great approach, but it seems like it would technically allow you to do what you wanted.This is an EXCELLENT approach to confuse the optimizer & produce poor performance.
    I suspect that using the same EXPLAIN PLAN to bring back 1 or and bring back all rows;
    will be suboptimal for a subset of all executions.

  • URGENT :::: Prepared Statement : Invalid Conversion Error

    Hi,
    I have prepared statement to update a database record. It is working fine but sometime it throws follow. SQLException. I checked the data I'm passing to the prepared statement. Everything works fine on the desktop but sometime it throws the foolow. exception on the websphere server.
    Error = SQL ERROR -99999 [IBM][CLI Driver] CLI0102E Invalid conversion. SQLSTATE=07006 In Method = performBulkOperation Of Class = com.bbh.actionworld.bulksql.BulkProcessing
    Its an urgent problem. Could you please help me ?
    thanks in advance.

    Hi
    I am using a prepared statement to insert records into an RDBMS. I am using JDK 1.4.1. I use setTime to set the date fields.
    My statement is
    pstmtAddFC.setTime(15, Time.valueOf("00:00:00"),
    Funcs.getCalendar(mydate));
    Where getCalendar sets the calandar to the date specified in mydate.
    I am using the JDBC:ODBC driver to connect to the database.
    This works fine with Oracle but gives
    java.SQL.Exception: [IBM][CLI Driver] CLI0102E Invalid Conversion. SQL STATE =07006
    Any suggestions? Thanks
    Regards
    Lakshmi

  • 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.

  • Prepared Statement - updating problem

    Hello all together!
    I've a problem and I hope somebody could help me out of misery!
    I have created a table and now I want to update a special cell and my aim is to use prepared statements
    I have generated it in the form mentioned below:
    public void setValueAt(Object newValue, int row, int col) {
    try {
    stmtPrep.setString(1, getColumnName(col)); // this should initalize the column I want to update
    stmtPrep.setObject(2, newValue); //this is the new value which should be set
    rowElements = getElementsOfRow(row);
    stmtPrep.setInt(3, (Integer.parseInt((String)rowElements[0]))); //this is my primary key
    stmtPrep.executeUpdate();
    stmtPrep.clearParameters();
    rs.updateRow();
    } catch (SQLException e) {e.printStackTrace(); }
    My SQL-Statement looks like this:
    private String queryPrep = "update Buch set ? = ? where isbn = ?";
    My problem is that column is not set.... am I not allowed to set column name in the prepared statement??
    how do I manage to show my changes in a master/detail implementation?
    anybode a clue????

    Hi majandrah,
    My SQL-Statement looks like this:
    private String queryPrep = "update Buch set ? = ?
    where isbn = ?";Sorry, not allowed.
    My problem is that column is not set.... am I not
    allowed to set column name in the prepared
    statement??No, you are not. Parameters can only be used for literal values -- not for names of columns , tables, etc.
    how do I manage to show my changes in a master/detail
    implementation?
    anybode a clue????I suggest using the java.text.MessageFormat class, like so:
    MessageFormat queryPrep = new MessageFormat("update BUCH set {0} = ? where ISBN = ?");
    String query = queryPrep.format(String[]{getColumnName(col)});
    // Now use your (posted) code, starting at line...
    stmtPrep.setObject(2, newValue);Good Luck,
    Avi.

  • Resultset from a batch select using prepared statement

    Hi,
    Is it possible to add results of batch execute of select statements and retrieve the result set ..
    I am running select statement in a batch mode setting in value for a column.I add this to a prepared batch.
    I would like to get the reults as a batch and spin through the result set like a r.next(). Is this possible ?
    I have given the code below
    sql = "select ordervalue , orderdate from discreet_orders "+
    "where order_no = ? ";
    dbObject.prepareStatement(sql);
    dbObject.prepareStatement(sql);
    for (int i=0; i < orderNoVect.size(); i++) {
    dbObject.setString(1,(String)scnV.elementAt(i));
    dbObject.addBatchPrepared();
    r = dbObject.execPrepared();
    dbObject.clearBatchPrepared();
    I would like to do a r.getNext() process the values form the resultset.
    Is this possible ? If not is there an other way to do it ?
    Thanks
    Arnold

    Olek wrote:
    hi
    Is there a way do a batch update using prepared statement?
    I don't want to insert every row in a single query...
    regards,
    OlekPossibly the confusion here stems from the existence of two addBatch methods in PreparedStatement.
    addBatch(String sql)inherited from Statement adds a new query to the batch of SQL statements for the statement. However you don't want to use this with PreparedStatements Instead you want
    addBatch()which adds the current set of parameters to the prepared statements batch of commands.
    In this scenario you prepare your query (insert statement) and then call setXXX(x,y) for each parameter and then addBatch for each tuple. Then call executeBatch to execute all the queries based on your batched parameters.
    If this didn't answer your question I don't know what your question is exactly. I would add that you probably want to set a "reasonable" size on your batches and break them into smaller batches as is reasonable. Mainly because the implementation of batched PreparedStatements widely varies depending on the database and driver, thus there are certainly scenarios where given enough batched parameters you could have various unpleasant things visited upon your program. Like terminal slowness, running out of memory, etc.

  • In new iPad 4g, when sim card is not inserted, I can not find the enable 4g tap in the setting-cellular data tap, can some one please tell me if this is normal and if so, then when it appears, thanks

    In new iPad 4g, when sim card is not inserted, I can not find the enable 4g tap in the setting-cellular data tap, can some one please tell me if this is normal and if so, then when it appears, thanks

    If the SIM is out of your phone, find my phone needs a data connection, so could use wifi - IF in range of a wifi and one that it can join (ie. a known network or one that is wholly open so no login required).  Your phone could also simple be turned off, so not findable, or it may have been restored (plugged into iTunes and restored as new) again, making it permanently unfindable.  Honestly, for someone stealing an iPhone, this is likely the first thing they do - restore as new and it is theirs forever.
    Find my iPhone is tied to the users iCloud account - the find function is part of the iCloud account's services and it communicates with the iCloud servers over a data connection - either wifi or 3G.
    Have you set up your iCloud account on your replacement phone, and is it working properly on that phone?

  • Error when trying to set a date type edit field

    Hi all
    I have an edit text field in a form which is bounded to a date type
    database field using dbDataSource.
    When i try to set the edit text field value with Today's date by code.
    I recieve an error message that the value which
    i'm trying to set is not legal. the  error number is [131-183].
    I use the following code to set the edit field:
    If oEditText.Value.Trim = String.Empty Then
                Dim strDate As String
                Dim sboBob As SAPbobsCOM.SBObob =
                 oCompany.GetBusinessObjec(SAPbobsCOM.BoObjectTypes.BoBridge)
                 rs = sboBob.Format_DateToString(Microsoft.VisualBasic.Today)
               strDate = rs.Fields.Item(0).Value.ToString().Trim()
    Try 
           oEditText.Value = strDate
    Catch ex As Exception
        SBO_Application.MessageBox("error setting
    current date: " & ex.Message)
    End Try
    End If
    My question is how can i set the edit field with a valid value?

    Hi!
    When writing to EditText.Value you must always use the B1 "DB-Format" as String.
    The following examples are assuming (it's a must!) that the EditText-Fields are bound to a corrosponding DataSource (Type Date, Price etc...)
    MyDateEditTxt.Value="20080207"
    MyPriceEditTxt.Value="1341.79"
    The best of it: It's Windows and SBO-GUI-Language independent.
    EditText.String must always be written with the format of the actual Language of the SBO-GUI, which can be changed by the user....
    You may also have a look at my statements regarding these problems near the end of this thread:
    [How to pass date value to an UDF;
    Cheers,
    Roland

  • I tried to up date my i phone 4 to iOS 5 then it wiped my phone and now it tells me to connect to iTunes and that the iPhone is in recovery mode and when i connect it goes to preparing to install to iPhone but never goes any further how do i restore

    i tried to up date my i phone 4 to iOS 5 then it wiped my phone and now it tells me to connect to iTunes and that the iPhone is in recovery mode and when i connect it goes to preparing to install to iPhone but never goes any further how do i restore the phone

    by reset option do you mean the DFU restore? worked for me, have you tried that?
    if not - hold the lock and home button until the power down bar comes up. then hold the lock button for ten seconds - next continue to hold the lock button and press the home button for ten seconds - next release the lock button and hold the home button for 10 seconds. this should be done with the phone tethered. If done right and your itunes is configured as such, the phone will reload the drivers and start up itunes, and then prompt for a restore/update.

Maybe you are looking for