SQL date problems

I have an old sql statement which is centered around dates as a contraint. When I run it through Oracles software (MYSQL plus), I am returned the correct records. But when running I run it through my web-app, nothing is returned to me. I guess the JDBC driver will interpret the sql statement a little differently. I know the problem is with the clause dealing with the dates, but am unaware of how to resolve it. Is there a better way of comparing dates? I am looking to find dates greater than tommorow's date. Here it is:
Thanks
AND (b.aq_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.m_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.me_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.ec_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.cxr_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.hs_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.bp_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.ps_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.cd_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.other_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.ts_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.sal_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.ir_follw_dte < to_char(sysdate+1,'dd-mon-yy')
OR b.br_follw_dte < to_char(sysdate+1,'dd-mon-yy'))

This is far too Oracle centric.
You'd be much better off using java.sql.PreparedStatement and let its setDate() method escape those Dates for you correctly:
Calendar calendar   = new GregorianCalendar();
java.util.Date tomorrow = calendar.add(Calendar.DAY_OF_YEAR, 1);
java.sql.Date tomorrowAsSql = new java.sql.Date(tomorrow.getTime());
String sql = "the rest of your query here"
+ "AND (b.aq_follw_dte < ?) "
+ "OR b.m_follw_dte < ?) "
+ "OR b.me_follw_dte < ?) "
+ "OR b.ec_follw_dte < ?) "
+ "OR b.cxr_follw_dte < ?) "
+ "OR b.hs_follw_dte < ?) "
+ "OR b.bp_follw_dte < ?) "
+ "OR b.ps_follw_dte < ?) "
+ "OR b.cd_follw_dte < ?) "
+ "OR b.other_follw_dte < ?) "
+ "OR b.ts_follw_dte < ?) "
+ "OR b.sal_follw_dte < ?) "
+ "OR b.ir_follw_dte < ?) "
+ "OR b.br_follw_dte < ?))";
PreparedStatement statement = connection.prepareStatement(sql);
statement.setDate(1, tomorrow);
statement.setDate(2, tomorrow);
// One setDate for each ? bind parameter
ResultSet result = statement.executeQuery();Now you don't have to worry about how to escape Dates, and this code works with any database.

Similar Messages

  • Sql.Date problem

    Hi,
    I am using java.sql.Date and preparedStatement for SQL select query, something like
    : select app_id, entry_date, message from testTable where entryDate >= ? and entryDate <= ?
    for example i'am supplying date as yesturday's date and i want data where
    say: 24-Oct-2005 12:00:00AM to 24-Oct-2005 11:59:59PM, basically whole days data.
    <code>
    SimpleDateFormat formatter =
    new SimpleDateFormat("dd-MMM-yyyy", Locale.US);
    SimpleDateFormat formatter1 =
    new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss aaa", Locale.US);
    String new1 = formatter1.format(formatter.parse(dateStr));
    System.out.println("new1 : "+ new1);
    Date date = new Date(formatter1.parse(new1).getTime());
    long nextDate = date.getTime()+(23*60*60*1000);
    System.out.println("d: " + date);
    System.out.println("next: " + new Date(nextDate));
    </code>
    problem is this code giving me same outputs, whereas, i need to supply, different timings to the same date.
    Thanks to anyone who can help me.

    I think the easier way is to use Calendar.getInstance() to return a Calendar instance and then use the various set() methods to set the time to midnight or the second before midnight of the next day.
    See the API docs for java.util.Calendar.
    - Saish

  • Please Help with sql.Date problem

    I have spent alot of time on what I thought would be an otherwise simple task, and I beleive I am close to completion but I need some much needed help. I have posted various forms of my code to try and acheive the solution but the responses received have been limited.
    I am trying to delete a record from a MS Access database where a Date/Time field in the database (Err_Date) equals a date entered by the user via a textbox.
    I finally have gotten the correct record to delete from the database, but what is very strange is that Tomcat is throwing a 'java.lang.NullPointerException' error. Then when I re-open the database the correct record is deleted.
    Here is my code:
    <%@page import="java.sql.*"%>
    <%@ page import="java.text.SimpleDateFormat"%>
    <%@ page import="java.util.Date"%>
    <%
    Connection con = null;
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    con = DriverManager.getConnection("jdbc:odbc:errorlog", "admin", "");
    catch(Exception e){
         out.println(e.getMessage());
    ResultSet rs=null;
    Statement stmt=null;
    try {
    stmt=con.createStatement();
    String end = request.getParameter("To");//FROM TEXTBOX
    java.text.SimpleDateFormat df = new java.text.SimpleDateFormat ("dd/MM/yyyy");
    java.util.Date d2 = df.parse(end);//CONVERT STRING TO UTIL DATE
    java.sql.Date date2 = new java.sql.Date(d2.getTime());//CONVERT TO SQL
    PreparedStatement stmnt = con.prepareStatement("DELETE FROM tblError WHERE Err_Date = ?");
    stmnt.setDate(1, date2);
    stmnt.executeUpdate();
    stmnt.close();          
    //CLOSE RESULT SET          
    rs.close();
         stmt.close();
    con.close();
    //CATCH EXCEPTIONS
    catch (SQLException e) {
         out.println(e.getMessage());
    %>

    well, in case anyone ever runs into a problem this stupid again the solution is as follows.
    the code to:
    1. retrieve date from text box
    2. covert string into util date
    3. convert util date into sql date
    4. delete from database
    is all correct.
    the problem is that I previously used String sql="SOME SQL DELETE" and then executed the result set, which of course I then had to close. This wasn't working so I switched to a Prepared Statement. I forgot to remove the 'rs.close()' statement in my code. So Tomcat was trying to close a result set that was never opened...

  • Problem Writing java.sql.Date to MS Access

    I have a relatively simple application that is for my own use (not distributed on an enterprise-wide basis). As I don't have an IT staff, I'm using a rudimentary Java front-end (v1.3.1) and a Microsoft Access backend.
    I seem to have trouble using INSERT/UPDATE statements with the MS Access Date/Time data type. Below is an example of code being used (id is defined as Text, amount is a Number and timestamp is Date/Time):
    conn = DriverManager.getConnection("jdbc:odbc:markets", "", "");
    conn.setAutoCommit(true);
    String sql = "INSERT INTO temp (id, amount, timestamp) VALUES (?, ?, ?)";
    PreparedStatement stmt = conn.prepareStatement(sql);
    String id = args[0];
    int len = id.length();
    java.sql.Date dt = new java.sql.Date(new java.util.Date().getTime());
    stmt.setString(1, id);
    stmt.setDouble(2, id.length());
    // I think the problem is here - the JDBC driver doesn't properly map dates to Access???
    stmt.setDate(3, dt);
    stmt.execute();
    stmt.close();
    conn.close();And I get the following error:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access
    Driver] Syntax error in INSERT INTO statement.
            at sun.jdbc.odbc.JdbcOdbc.createSQLException (JdbcOdbc.java:6879)
            at sun.jdbc.odbc.JdbcOdbc.standardError (JdbcOdbc.java:7036)
            at sun.jdbc.odbc.JdbcOdbc.SQLExecDirect (JdbcOdbc.java:3065)
            at sun.jdbc.odbc.JdbcOdbcStatement.execute (JdbcOdbcStatement.java:338)
            at TestWritingDate.main(TestWritingDate.java:31) I'm virtually certain this is a translation problem with
    the java.sql.Date and the JDBC driver. But I can't seem
    to overcome this. Any help is DESPERATELY needed.
    Thanks.
    Matt

    That was it....thanks...didn't even consider that....perhaps I should start using class names that are already in use too :-). Thanks again...

  • Problem in converting util date format to sql date format

    im trying to convert util date to sql date...i'm getting the error msg as
    Error is : java.lang.NullPointerException
    Error Message : null
    i'm not bale to track the result...whatz the problem with this code?
    This fromDate value will be dynamically built, value will be
    fromDate="Tue Jul 15 00:00:00 IST 2003";
    java.util.Date xx=util.stringToDate(fromDate);
    java.sql.Date sqlD=null;
    sqlD.setTime(xx.getTime());
    System.out.println("sqld"+sqlD);

    I try this and it works:
    SimpleDateFormat simpledateformat = new SimpleDateFormat("EEE MMM dd HH:mm:ss z yyyy", Locale.UK);
    String s = "Tue Jul 15 00:00:00 IST 2003";
    java.util.Date date = simpledateformat.parse(s);
    java.sql.Date sqlD=new java.sql.Date(date.getTime());
    System.out.println("sqld"+sqlD);
    Hope this helps.

  • PreparedStatement.setDate(1,java.sql.Date x) problem

    I am using Sun JDBC-ODBC bridge to access MS SQL Server 2000. I have following statement:
    java.util.Date date = new java.util.Date();
    java.sql.Date expire_date = new java.sql.Date(date.getTime());
    PreparedStatement pstat = con.prepareStatement("update account set expire_date=? where userid=?");
    pstat.setDate(1,expire_date);
    pstat.setString(2,userid);
    When I ran the program, I got a SQLException error as
    java.sql.SQLException: [Microsoft][ODBC SQL Server Driver]Optional features not implemented.
    I have traced the problem happened in the statement pstat.setDate(1,expire_date). I use jdbc-odbc bridge from j2se 1.3.1.
    I appreciate any help.
    Thanks, Brian

    May I refer to a recent topic where I explained a lot about date conversion between JDBC and SQLServer?
    http://forum.java.sun.com/thread.jsp?forum=48&thread=241049
    Try how far this helps you, then ask more.

  • SQL Data Sync - error during sync. Unable to diagnose the problem.

    I have 2 SQL data sync groups setup
    First one does a 1 way sync from azure to local db. Sync's only 1 table.
    Second one does a 1 way sync from local db to the azure. Syncs 2 tables.
    After setting it up and getting a few sync errors I was able to figure out what's wrong by checking the logs and fixing the problems. It was all running fine for a while and now it broke down.
    I got a sync error every time sync is attempted - however this time I'm not able to fix anything because I don't have any visibility on what's wrong - when I click on the Log tab in the Azure Management portal it just stays blank - no details come up.
    I click [Logs] Wait spinner comes up 
    And then it looks like this: 
    Another detail worth mentioning is that the error only occurs for the Second sync group that I have.
    Here's what I've attempted so far
    I poked around the azure management portal to try to find another way of looking at the logs - looking for something like ftp access to the log file - couldn't find anything like that.
    I refreshed schema in the sync rules tab.
    Used the SQL Data Sync agent tool on the premise to do the ping operation. Restarted the sql data sync windows service.
    Made sure I have the latest SQL Data Sync Agent installed.
    I'm wondering what are my options from here...
    I'm close to trying to deleting and recreating the sync group... I'm not too comfortable doing this because I know there are some sql tables that get created in the local db to support the operation of the sync - so if I delete the sync group would that automatically
    drop those helper tables as well or would I have to drop those manually - If I do drop those then that will obviously brake the other sync group that works fin as well..
    Any advice is appreciated. Thanks

    hi,
    According to your description, it seems the issue is related to SQL Azure, I will move this thread to SQL Azure Discussions forums to get a better support.
    Regards,
    Will
    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.

  • Linked Server Problem while SQL Data Transfer using Non-sys Admin Account

    Hi Team,
    I've an issue while transferring the data from ServerA to ServerB. I've made the ServerB as "Linked Server" to Server A. Pre requisite like:
    1) SQL Account is been created on ServerB.
    2) Timeout settings for remote connections is set to "No Timeout".
    When I execute the below script using Query Window, It executes successfully:
    Insert into ServerB.DBName.dbo.TableName1
    Select * from dbo.TableName1
    But when I execute the same step by creating a SQL Job, it fails with the below error message:
    Message
    Executed as user: DomainName\UserName. Named Pipes Provider: Could not open a connection to SQL Server [1450]. [SQLSTATE 42000] (Error 1450)  OLE DB provider "SQLNCLI" for linked server "ServerB" returned message "Login
    timeout expired". [SQLSTATE 01000] (Error 7412)  OLE DB provider "SQLNCLI" for linked server "ServerB" returned message "An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005,
    this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.". [SQLSTATE 01000] (Error 7412).  The step failed.
    Could you please help me in fixing the above error message and I can transfer the SQL Data between 2 Servers.
    Thank You
    Sridhar D Naik

    Sridhar,
    Is this still an issue?
    Thanks!
    Ed Price, Azure & Power BI Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • Help needed with missing data problem in CRVS2010

    We recently upgraded the reporting engine in our product to use Crystal Reports for Visual Studio 2010 (previously engine was CR9). Our quote report, which has numerous subreports and lots of conditional formatting, started losing data when a quote took more than a single page to be printed. We knew the SQL results included the data, but the report was not printing those lines at all or sometimes printing a partial line. In addition, the running total on the report would exclude the lines that were being missed on the next page. In one example submitted by a customer, 3 lines were skipped between pages.
    I think I have identified two potential issues that document the possibility of data not being included in the report.
    The first potential issue is an issue with the "suppress blank section" option being checked. This issue is supposedly fixed with ADAPT01483793, being released someday with service pack 2 for CRVS2010.
    The second potential issue is using shared variables. This issue is supposedly fixed with ADAPT01484308, also targeted for SP2.
    Our quote report does not explicitly use shared variables with any of the subreports, but it does have several subreports, each in its own section that has the "supress blank section" option checked. We have other reports that use this feature, as well, and they are not exhibiting the problem.
    One different thing about the quote report is that it has a section with multiple suppression options selected. The section has a conditional suppression formula, which controls whether the section is included at all within the report. The section also has the suppress blank section option selected. There are multiple fields within the report that are each conditionally suppressed. In theory, the section's suppress formula could evaluate to true, yet all of the fields within the section are suppressed (due to null values), and then the "suppress blank section" option would kick in.
    The missing data only seems to happen when the section is not being suppressed, and at least one of the fields is being included in the report. If I clear the "suppress blank section" check box, and change the section formula to also include the rules applied to the fields in the section, the missing data problem seems to be resolved.
    Is this related to ADAPT01483793? Will it be fixed in service pack 2?
    If more details are needed, I would be happy to provide a sample report with stored data.

    Hi Don,
    Have a look at the Record Selection formula in CR Designer ( stand alone ) and when exported to RPT format opening that report in the Designer also. 
    There's been a few issues with => logic in the record selection formula. It could be you are running into this problem. Look for NOT inserted into your selection formula.
    Oh and SP2 is coming out shortly so it may resolve the issue. But if you want you could purchase a support, or if you have a support contract then create a case in SMP and get a rep to work with you to debug the issue.
    If you have not try the Trial Version of CR 2011, put it on a VM-ware image or Test PC so you don't corrupt anything for production and have a look at and test it in that designer also. If you purchase a case and it is a bug then you'll get a credit back for the case.
    Don
    Edited by: Don Williams on Oct 26, 2011 7:40 AM

  • Using a SQL data source and XML data source in the same template

    I am trying to develop a template for the Request for Quote report generated in Apps 11.5.10. I have loaded the data from the XML output into the template, but I am missing one field - I need the org_id from the po_headers table. Is it possible to use a sql data source (i.e., "select org_id from po_headers_all where po_header_id = [insert header_id from xml data]...") in addition to the xml data source to populate the template at runtime? When you use the Insert > SQL functionality is it static at the time the template is created, or does it call to the database at runtime? I've looked through all the docs I could find, but this isn't clear.
    Thanks for any help or suggestions you may have.
    Rhonda

    Hi Pablo
    Thats a tough one ... if you go custom with a data template you will at least get support on the data template functionality ie you have a problem when you try and build one. You will not get support on the query inside the data template as you might have gotten with the Oracle Report, well you could at least log a bug against development for a bad query.
    Eventually that Oracle Report will be converted by development anyway, theres an R12 project going on right now to switch the shipped OReports to data templates. AT this point you'll be fully supported again but:
    1. You have to have R12 and
    2. You'll need to wait for the patch
    On reflection, if you are confident enough in the query then Oracle will support you on its implementation within a data template. Going forward you may be able to swap out your DT and out in the Oracle one without too much effort.
    Regards, Tim

  • Poblem with java.sql.Date while inserting to a table

    Hi All,
    I have a PostgreSQL database table which contains fields(columns ) of type date. I want to insert values to the table in the[b] �dd-MMM-YYYY� format using the prepared statement.
    My code is as follows
    java.text.DateFormat dateFormatter =new java.text.SimpleDateFormat("dd-MMM-yyyy");
    String formatedDate=dateFormatter.format(theDate);
    currentDate = new java.sql.Date(dateFormatter.parse(formatedDate).getTime())
    �������������������
    �������������������
    �������������������
    pst.setDate(12,currentDate);The problem is the currentDate variable gives date only in the �YYYY-MMM-dd� format but requirement is the currentDate variable should give date in the �dd-MMM-YYYY� format and this should be save to table as java.sql.Date type
    There is any solution???? please help me...
    Thanks and Regards,
    Hyson_05

    Hi,
    What are you talking about? A Date does always wrap a millisecond value, and doesn't have any formatting. It's the database, or your program which formats the date that you see.
    In short. You should format the value when you print it, and not when you store it.
    Kaj

  • Infopath form taking long time to load sql data

    In infopath form having with multple views. In one of the view SQL Data will be loaded on selection of dropdown to repeating table.  If it is lessthan 1000 items its working, if it is morethan 1500 items form will hanging for 15-20 mins. 
    Form is developed by C# code.  Can anyone suggest to relsolve this issue.  Thanks in Advance.

    Hello,
    I also had same problem while querying connection via rule so i gave chance to code and query executes within 2-5 seconds which was taking 10-15 mins earlier. Try this
    AdoQueryConnection myAdoQueryConnection = (AdoQueryConnection)(this.DataConnections["SQL Con"]);
    myAdoQueryConnection.Command = "select * from table1 where col1 = " + "'" + InstallationID + "'";
    myAdoQueryConnection.Timeout = 60;
    myAdoQueryConnection.Execute();
    Hope it could help
    Hemendra:Yesterday is just a memory,Tomorrow we may never see<br/> Please remember to mark the replies as answers if they help and unmark them if they provide no help

  • Java.sql.Date vs java.util.Date vs. java.util.Calendar

    All I want to do is create a java.sql.Date subclass which has the Date(String) constructor, some checks for values and a few other additional methods and that avoids deprecation warnings/errors.
    I am trying to write a wrapper for the java.sql.Date class that would allow a user to create a Date object using the methods:
    Date date1 = new Date(2003, 10, 7);ORDate date2 = new Date("2003-10-07");I am creating classes that mimic MySQL (and eventually other databases) column types in order to allow for data checking since MySQL does not force checks or throw errors as, say, Oracle can be set up to do. All the types EXCEPT the Date, Datetime, Timestamp and Time types for MySQL map nicely to and from java.sql.* objects through wrappers of one sort or another.
    Unfortunately, java.sql.Date, java.sql.Timestamp, java.sql.Time are not so friendly and very confusing.
    One of my problems is that new java.sql.Date(int,int,int); and new java.util.Date(int,int,int); are both deprecated, so if I use them, I get deprecation warnings (errors) on compile.
    Example:
    public class Date extends java.sql.Date implements RangedColumn {
      public static final String RANGE = "FROM '1000-01-01' to '8099-12-31'";
      public static final String TYPE = "DATE";
       * Minimum date allowed by <strong>MySQL</strong>. NOTE: This is a MySQL
       * limitation. Java allows dates from '0000-01-01' while MySQL only supports
       * dates from '1000-01-01'.
      public static final Date MIN_DATE = new Date(1000 + 1900,1,1);
       * Maximum date allowed by <strong>Java</strong>. NOTE: This is a Java limitation, not a MySQL
       * limitation. MySQL allows dates up to '9999-12-31' while Java only supports
       * dates to '8099-12-31'.
      public static final Date MAX_DATE = new Date(8099 + 1900,12,31);
      protected int _precision = 0;
      private java.sql.Date _date = null;
      public Date(int year, int month, int date) {
        // Deprecated, so I get deprecation warnings from the next line:
        super(year,month,date);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public Date(String s) {
        super(0l);
        // Start Cut-and-paste from java.sql.Date.valueOf(String s)
        int year;
        int month;
        int day;
        int firstDash;
        int secondDash;
        if (s == null) throw new java.lang.IllegalArgumentException();
        firstDash = s.indexOf('-');
        secondDash = s.indexOf('-', firstDash+1);
        if ((firstDash > 0) & (secondDash > 0) & (secondDash < s.length()-1)) {
          year = Integer.parseInt(s.substring(0, firstDash)) - 1900;
          month = Integer.parseInt(s.substring(firstDash+1, secondDash)) - 1;
          day = Integer.parseInt(s.substring(secondDash+1));
        } else {
          throw new java.lang.IllegalArgumentException();
        // End Cut-and-paste from java.sql.Date.valueOf(String s)
        // Next three lines are deprecated, causing warnings.
        this.setYear(year);
        this.setMonth(month);
        this.setDate(day);
        if(! isWithinRange(this))
          throw new ValueOutOfRangeException((RangedColumn)this, "" + this);
      public static boolean isWithinRange(Date date) {
        if(date.before(MIN_DATE))
          return false;
        if(date.after(MAX_DATE))
          return false;
        return true;
      public String getRange() { return RANGE; }
      public int getPrecision() { return _precision; }
      public String getType() { return TYPE; }
    }This works well, but it's deprecated. I don't see how I can use a java.util.Calendar object in stead without either essentially re-writing java.sql.Date almost entirely or losing the ability to be able to use java.sql.PreparedStatement.get[set]Date(int pos, java.sql.Date date);
    So at this point, I am at a loss.
    The deprecation documentation for constructor new Date(int,int,int)says "instead use the constructor Date(long date)", which I can't do unless I do a bunch of expensive String -> [Calendar/Date] -> Milliseconds conversions, and then I can't use "super()", so I'm back to re-writing the class again.
    I can't use setters like java.sql.Date.setYear(int) or java.util.setMonth(int) because they are deprecated too: "replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date)". Well GREAT, I can't go from a Date object to a Calendar object, so how am I supposed to use the "Calendar.set(...)" method!?!? From where I'm sitting, this whole Date deprecation thing seems like a step backward not forward, especially in the java.sql.* realm.
    To prove my point, the non-deprecated method java.sql.Date.valueOf(String) USES the DEPRECATED constructor java.util.Date(int,int,int).
    So, how do I create a java.sql.Date subclass which has the Date(String) constructor that avoids deprecation warnings/errors?
    That's all I really want.
    HELP!

    I appreciate your help, but what I was hoping to accomplish was to have two constructors for my java.sql.Date subclass, one that took (int,int,int) and one that took ("yyyy-MM-dd"). From what I gather from your answers, you don't think it's possible. I would have to have a static instantiator method like:public static java.sql.Date createDate (int year, int month, int date) { ... } OR public static java.sql.Date createDate (String dateString) { ... }Is that correct?
    If it is, I have to go back to the drawing board since it breaks my constructor paradigm for all of my 20 or so other MySQL column objects and, well, that's not acceptable, so I might just keep my deprecations for now.
    -G

  • MS Access Date problem (from Java program)

    I have written an app. in Java that reads & writes data from a MS Access database.
    I am trying to write an insert class which will add a row of data to one of my database tables - which contains Date fields.
    My problem is that I can update the text fields, but not Date fields - every time I try my program throws an exception:
    java.sql.SQLException: [Microsoft][ODBC Microsoft Access Driver] Syntax error in INSERT INTO statement
    My simplified code reads as:
    try {
    Statement insertStatement = databaseConnection.createStatement();
    String query = "INSERT INTO myTable(jobId, employeeId, date) VALUES('11', '1', " + "'13/11/2006'" + ");";
    insertStatement.execute(query);
    } //close, etc. etc.
    If I remove the date info from the query, the program executes successfully. I appreciate my problem might be related to the formatting of the date in Access, and if not a 'proper' Java question I give my apologies.
    I have attempted several formats of the date with no success or variation in the exception.
    I am, however, completely stuck and would appreciate any and all help given.
    Regards and thanks
    David

    I have amended my code to use a preparedStatement, but on execution I have the same problem.
    My code is as follows:
    PreparedStatement pstmt = null;
    try {
    String query = "INSERT INTO myTable (jobId, employeeId, date) VALUES(?, ?, ?);";
    pstmt = databaseConnection.prepareStatement(query);
    pstmt.setString(1, "11");
    pstmt.setString(2, "1");
    java.sql.Date sqlDate = getCurrentJavaSqlDate();
    pstmt.setDate(3, sqlDate);
    // execute query, and return number of rows created
    int rowCount = pstmt.executeUpdate();
    System.out.println("rowCount=" + rowCount);
    pstmt.close();
    catch, etc. etc.
    Any ideas or help most welcome
    Regards
    David

  • Convert java.sql.Date to oracle.jbo.domain.Date in oaf

    Hi,
    Need to dafault NeedBydate(i get in from query as below) to a messagelovinput and make it read only.
    i am facing some issue in converting from java.sql.Date to oracle.jbo.domain.Date.
    unable to figure out the problem.
    below is the sample code im trying to use.
    PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
    ResultSet rs=ps.executeQuery();
    if (rs!=null && ps.next()
    java.sql.Date sqlDate= rs.getDate(1);
    oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
    vorow.setAttribute("Datevalue",oracleDate);
    this is my assumption : to set to UI i need date in format dd-Mon-yyyy.(am i correct? as to get that format i tried to use simple date format class but no use)
    when i tried to use simple date format :unpaseable date exception was raised.
    please guide.

    Hi,
    Why are you using this code???
    PreparedStatement ps=pageContext.createPreparedStatement("select sysdate from dual");
    ResultSet rs=ps.executeQuery();
    if (rs!=null && ps.next()
    java.sql.Date sqlDate= rs.getDate(1);
    oracle.jbo.domain.Date oracleDate = new oracle.jbo.domain.Date(sqlDate.getTime());
    you can get sysdate using this and then set it
    oracle.jbo.domain.Date currentDate = am.getOADBTransaction().getCurrentUserDate();
    java.text.SimpleDateFormat displayDateFormat = new java.text.SimpleDateFormat ("yyyy-MM-dd");
    String DateForm = displayDateFormat.format(currentDate.dateValue());
    oracle.jbo.domain.Date dateset = new oracle.jbo.domain.Date(DateForm);
    and then set the attribute
    vorow.setAttribute("Datevalue",dateset);
    Thanks,
    Gaurav

Maybe you are looking for

  • Would working from a locked project file cause problems?

    Hi all. working in FCP 4.5 on numerous Dual G5s (2.0 & 1.8 GHz) with sufficient RAM (4 GB+). I'm working on a large project with a number of editors and I've created projects that each editor can use as references to the material. I lock the referenc

  • When trying to sync, it says "sync session failed to start." Any suggestions?

    I have a a new 4S, OS up to date.

  • How do I "Close Dashboard Client"?

    I am trying to install Adobe Flash Player 10 on my MacBook Pro. However, the installation does not take place because I continue receiving an error that says I must "Close Dashboard Client". What does that mean, and how do I accomplish that? I search

  • Boot Camp & Snow Leopard

    Hi forum. I've used BC on 10.5 often. It works great. My question is this: Does anyone know if there are any differences with the BC Drivers on the 10.5 DVD compared to the BC Drivers on the 10.6 DVD? Assuming there are BC Drivers on 10.6 DVD. I have

  • My mail inbox is empty

    Just got my brand new MacBook Air today, and I am configuring the mail application. But somehow my inbox appears to be empty. It says I have 343 unread mails, but it won't show them. What am I doing wrong? Instead my mails are listed under a GMAIL fo