EJB - Oracle Date Field

hello
how can i insert a date field into oracle table using EJB?
now i'm using java.sql.Timestamp, but it's deprecated
bye
ACS

Hi Antonio,
Since when is java.sql.Timestamp deprecated?
I am using OC4J version 1.0.2.2 with JDK 1.2.2 (that comes with 9iAS)
and I use java.sql.Timestamp all the time in my applications without
any problems. Here is an example using JDBC:
java.sql.Timestamp timestamp = new java.sql.Timestamp(System.currentTimeMillis());
Connection conn = DriverManager.getConnection();
String sql = "UPDATE my_table SET my_date_col = ?";
PreparedStatement ps = conn.prepareStatement(sql);
ps.setTimestamp(1, timestamp);
ps.executeUpdate();
What am I missing?
Good Luck,
Avi.

Similar Messages

  • How to convert SAP dateTime field to Oracle date field

    Hi All,
                We have a scenario where the incoming data is in the following format:
    < ReconciliationData >
        < RowID > 9 </ RowID > 
        < Run_ID > 7 </ Run_ID > 
        < Control_ID > 5.40 </ Control_ID > 
        < Control_Name > MTD CHARGES TO CARP ORDERS INVENTORY </ Control_Name > 
        < Start_Month > 008 </ Start_Month > 
        < End_Month > 008 </ End_Month > 
    <b>   < SAP_Time > 20070828190545 </ SAP_Time > </b>
        < SAP_Count > 4 </ SAP_Count > 
        < SAP_Amount > 5000.00 </ SAP_Amount > 
        </ ReconciliationData >
    On the receiver side is oracle database. SAP TIME field has to go into Oracle Date field. it should be transformed to structure yyyy/mm/dd hh:mm:ss format.
    How do i go about doing it?
    Regards,
    XIer

    hey
    did u try the DateTrans function?if that does not work then u can write a simple UDF for it
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/frameset.htm
    Thanx
    Aamir

  • Problem with updating Time component of an Oracle Date field in ALBPM

    Hi.
    I'm new to ALBPM and am experiencing the following problem I hope someone can take the time to help out with.
    I'm using a Date and Time Picker element in a Form to enter the date and time information. Within ALBPM the date and time representation appears correct as it prints out what I've entered. The logMessage displays this information in the form "YYYY-MM-DD HH24:mm:ss+TimezoneOffset". The BPM Object that stores this value is referencing an Oracle table that has an equivalent Date field. My problem is that it appears to only update the Date component.
    I've also tried using the native Time variable type within ALBPM be adding an variable of type Time to the BPM Object and setting the result Database object equal to this Time variable with the same result. The Time variable was declared with Timestamp precision (take this to mean both Date and Time components).
    Has anyone come across this problem? I'm using ALBPM Studio 6.0 M3 as my release.
    Thanks.

    I must have deselected the "Use Timestamp for Date columns" in the Advanced tab within the External Resource definition for my database at some point in time. Enabling this option fixed my problem - silly me.

  • Oracle Date Field Exception

    When using the ODP.NET provider version 2.111.6.20 to access an Oracle 9i database we get errors with some date fields. We can read most records fine, however, on some records we get an exception "Year, Month, and Day parameters describe an un-representable DateTime"
    We get this error the second we try to access the field. It doesn't matter how we access it we still get the error.
    We are using an OracleDataReader object and have tried the following.
    object o = reader["FieldName"];
    object o = reader.GetValue(i);
    string s = reader.GetValue(i).ToString();
    string s = reader["FieldName"].ToString();
    Oracle.DataAccess.Types.OracleDate d = (Oracle.DataAccess.Types.OracleDate)reader;
    Oracle.DataAccess.Types.OracleDate d = reader.GetOracleDate(i); * This returns a different error. It says "ORA-1866: the datetime class is invalid"
    DateTime d = reader.GetDateTime(i);
    I'm pretty well stumped at this point. I can't get this record & field to do anything but throw an exception whenever accessed in .Net.
    However, if I query the table in Oracle SQL Developer it shows the value 31-DEC-01 for the field.
    Thanks for any assistance.

    Hi,
    My guess is you may have invalid data stored. Or, at least I'd check that.
    If you issue this query, does anything come back as 00-000-0000 00:00:00 ?
    select to_char(<columnname>,'dd-mm-yyyy hh24:mi:ss') from <tablename>;
    If you have access to Metalink the following note may help:
    Note 95402.1 - Baddate Script To Check Database For Corrupt dates
    Cheerrs
    Greg

  • Oracle date field not comparing properly with to_date function

    Hi, i'm facing a very weird problem. I'm triyng to retrieve a range of records in between two dates. However, it doesn't seem to understand. What am i doing wrong?
    let's say my table (MYRECORD) has this (where id is varchar and date is DATE and not timestamp) :
    ID DATE
    1 22-JAN-08
    2 22-JAN-08
    3 21-JAN-10
    4 11-FEB-10
    5 11-FEB-10
    So, let's say iwanna get the records from 21st Jan 2010 :
    select
    date as ori_date from MYRECORD where
    date = to_date('21/01/2010','DD/MM/YYYY')
    1.)
    it is not returning any record at all. I'm having problems with between dates and the to_date function as well,
    so i'm trying to get the 'equal' part working first. I can't use to_char because at the end of the day,
    i need to compare between dates.
    what am i doing wrong? has this got anything to do with what kind of format is set up on the oracle server?
    running :
    SELECT value FROM v$nls_parameters WHERE parameter ='NLS_DATE_FORMAT'
    returns DD-MON-RR
    2.) how do we compare dates from the table according to our own specified format from our passed string? I only have READONLY access to this database
    so i can't set anything up.

    please run this
    select To_date(date, 'DD/MM/YYYY HH24:MI:SS') as ori_date from MYRECORDprobably you have hour minute second info in your table, to_date('01012010','DDMMYYYY') means hour, minute and second is 00:00:00 so it wont be equal.The database field type is actually 'DATE' and not datetime. I've also ran the sql you provided to show its timestamp, but it's not showing anything as far as timestamp is concerned. It's showing only the date. So does this mean it's a real date only information?
    However, it might be more efficient to do two comparisons, especially if there's an index on dt:
    WHERE   dt >= TO_DATE ('21/01/2010', 'DD/MM/YYYY')
    AND     dt <  TO_DATE ('22/01/2010', 'DD/MM/YYYY')
    Ok. If we change the range to compare it on the same day, it won't work;
    WHERE   dt >= TO_DATE ('21/01/2010', 'DD/MM/YYYY')
    AND     dt <=  TO_DATE ('21/01/2010', 'DD/MM/YYYY')this also happens if we're using BETWEEN
    this is real weird. It's supposed to work...i don't recall having this kind of issue on other databases. If that's the case,
    each time a user passes me a date string i have to somehow add another day onto its 'to' comparison date in order for things to work.
    but..i don't want to since i don't want to accidentally include the extra day's results!
    Edited by: 803998 on Oct 21, 2010 8:14 PM
    Edited by: 803998 on Oct 21, 2010 8:33 PM

  • Question on using a Parameter against an Oracle date field

    Post Author: klkemp100
    CA Forum: Data Connectivity and SQL
    newbie here just getting started in Crystal Reports v11.0
    writing a report to go against an oracle view. i need the report to use a parameter that the user enters to select a specific date.
    i went through the database expert and keyed in my own sql since i first tested this via TOAD and know that the sql works fine with a hard-coded date etc.
    next i created a parameter and set it first up as a DATE but got the message that FAILED TO RETRIEVE DATA FROM THE DATABASE, even though I know that there is data to retrieve and i have previously retrieved it when the selection date is hard-coded in the query.
    i then changed the field type in the view to be a VARCHAR2 and changed the parameter to be a STRING, but am still getting the same thing.
    is there something special about using dates and parameters within crystal against oracle?
    thanks in advance for your help.

    Post Author: amr_foci
    CA Forum: Data Connectivity and SQL
    you also may check the date format , oracle maybe excpecting you to send the parameter in some format and you are sending it into another format
    if both are type dates in report and database you can use this
    where to_date(to_char(mytable.my_date_field,'dd/mm/yyyy'),'dd/mm/yyyy') = to_date(to_char(,'your_format'),'dd/mm/yyyy')
    you may use this in a free hand SQL
    good luck

  • Bizare date field behavior in an Oracle database.

    I have this bizare data problem quering an oracle date field.
    Look at these two result sets.
    Missing Two records.:
    COUNTY_CD
    CONAME
    FILE_DATE
    TRANSMISSIONS
    RECORDS
    NO_ERROR_RECORDS
    ERROR_RECORDS
    TOTAL_ERRORS
    03   
    AMADOR                    
    07-NOV-11            
    10                
    405               
    396               
    9                 
    9                 
    10   
    FRESNO                    
    07-NOV-11            
    1                 
    204               
    200               
    4                 
    4                 
    16   
    KINGS                     
    07-NOV-11            
    3                 
    1296              
    1110              
    186               
    194               
    20   
    MADERA                    
    07-NOV-11            
    1                 
    552               
    535               
    17                
    17                
    51   
    SUTTER                    
    07-NOV-11            
    1                 
    43                
    5                 
    38                
    38                
    WHERE
            r.file_date BETWEEN TO_DATE('2011-11-07 00:00:00','YYYY-MM-DD HH24:MI:SS')
                            AND TO_DATE('2011-11-07 15:00:00','YYYY-MM-DD HH24:MI:SS')
    All Expected records
    COUNTY_CD
    CONAME
    FILE_DATE
    TRANSMISSIONS
    RECORDS
    NO_ERROR_RECORDS
    ERROR_RECORDS
    TOTAL_RECORDS
    03   
    AMADOR                    
    07-NOV-11            
    10                
    405               
    396               
    9                 
    9                 
    10   
    FRESNO                    
    07-NOV-11            
    1                 
    204               
    200               
    4                 
    4                 
    16   
    KINGS                     
    07-NOV-11            
    3                 
    1296              
    1110              
    186               
    194               
    20   
    MADERA                    
    07-NOV-11            
    1                 
    552               
    535               
    17                
    17                
    50   
    STANISLAUS                
    07-NOV-11            
    2                 
    17002             
    7165              
    9837              
    10028             
    51   
    SUTTER                    
    07-NOV-11            
    1                 
    43                
    5                 
    38                
    38                
    WHERE
            r.file_date BETWEEN TO_DATE('2011-11-07 00:00:00','YYYY-MM-DD HH24:MI:SS')
                            AND TO_DATE('2011-11-07 15:59:59','YYYY-MM-DD HH24:MI:SS')
    Can anybody tell me why looking for recrods by the FILE_DATE field that has no time portion, it is a 'DATE' data type field, would produce different results based on different time parameters passed into the WHERE clause?  This has me really confused and I just can not figure out why this behavior changes which makes me leary to trust a work around solution of just apending random time data to the where clause.
    Below it the entire SQL query from the origanal source.
    SELECT
    r.county_cd,
    c.coname,
    COUNT(unique r.file_name) AS transmissions,
    count(r.use_no) AS records,
    count(r.use_no) - count(e.use_no) AS no_error_records,
    count(e.use_no) AS error_records,
    sum(e.errors) AS total_errors
    FROM
    raw_pur r INNER JOIN
    pur_lookup l
    ON (r.use_no = l.use_no AND r.year = l.seq_year) LEFT OUTER JOIN
    SELECT
    year,
    use_no,
    count(use_no) AS errors
    FROM
    errors
    WHERE
    NOT (error_code = 17 OR error_code = 20 OR error_code = 72 OR error_code = 52 OR
    (error_code = 12 AND error_type = 'POSSIBLE') OR
    (error_code = 69 AND error_type = 'POSSIBLE') OR
    (error_code = 37 AND error_type = 'POSSIBLE') OR
    (error_code = 39 AND error_type = 'POSSIBLE'))
    GROUP BY
    year,
    use_no
    ) e ON (r.year = e.year AND r.use_no = e.use_no) INNER JOIN
    county c
    ON (r.county_cd = c.county_cd)
    WHERE
    r.file_date BETWEEN <cfqueryparam value="#form.fromDate#" cfsqltype="cf_sql_date">
    AND <cfqueryparam value="#form.toDate#" cfsqltype="cf_sql_date">
    GROUP BY
    r.county_cd,
    c.coname
    ORDER BY
    r.county_cd

    Thanks guys.  The errant records in question do indeed have time portions to the values in the FILE_DATE field, though they are not supposed to and all the other records do not.
    Thanks for the suggestion to use the to_char function to suss out the actual, full values. 
    It is always so useful to have helpful IDEs (Oracle SQL Developer in my case) that hide information from you.  I was using this to look at the field expecting to find time data, but was not seeing it.  I guess SQL developer is formatting the date-time value for me since this is a date field.  How helpful in a debugging situation.
    Now to figure out why these records are in the database in this way in the first place.  Because they are not supposed to be.
    Again, thanks for the help.
    Ian

  • Keep Oracle DATE datatype but insert via PreparedStatement with time

    I know there are alot of messages concerning java.sql.Date and that it doesn't
    hold the time.
    Can you give me an example of how to insert Date and Time into an Oracle
    "DATE" field using preparedStatements?
    dailysun

    java.util.Date d = new java.util.Date();
    java.sql.Timestamp ts = new java.sql.Timestamp(d.getTime());
    prepStatement.setTimestamp(1, ts);

  • Is there any chance that ORacle RDBMS persuades ODBC to consider Oracle Date type as Date without time

    Hello,
    I have complain from SPSS end user reaching Oracle through ODBC interface that Oracle date fields are considered as datetime fields in SPSS.
    It is the whish that SPSS would consider Oracle date field right from the beginning as date field without the need to reformat field...
    In SPSS dictionary field is described as DATETIME20 after query from the database.
    Any idea is apreciated,

    I just double check and didn't see this option anywhere. You can however copy/paste text on a BlackBerry. I believe the only way would be to copy it in your email client and have the BlackBerry synchronize with it
    If someone has been helpful please consider giving them kudos by clicking the star to the left of their post.
    Remember to resolve your thread by clicking Accepted Solution.

  • How to load date field from a remote Oracle DB with DB Connect

    Hi,
    Does any one have experience extracting Date field from a remote Oracle database through DB Connect to BW?  I am experiencing data format issue.  The extracted data shows '04-Oct-0' for '10/4/05'.  It works fine if I create a view in Oracle database to preformat the data to '20051004'.  But, I am not allowed to create view in Remote DB.
    Any suggestion is very appreciated.
    Regards,
    Frank

    You have to change it to a varchar2 field. YYYYMMDD. I do not know of any other option.

  • Insert current date and time into Oracle date type field

    I have a JDBC current date and time insert into Oracle 9i that almost works. It submits the current date and a fixed time into the Oracle date type field. I am using Tomcat 6.0.20.
    For example if I insert the data at 7:24:04 PM on Feb 16, 2010 it will insert as: 16-Feb-2010 12:00:00 AM
    The date part works but the time always shows 12:00:00 AM no matter what date or time the data is inserted.
    Here is what I have for my JDBC inserts and I also tried something with DateFormat:
    PreparedStatement ps; Date mydate = new Date(new java.util.Date().getTime()); //insert statement here.... stmt.setDate(1,mydate);
    I also tried:
    PreparedStatement ps; java.sql.Timestamp mydate = new java.sql.Timestamp(new java.util.Date().getTime()); SimpleDateFormat fmt = new SimpleDateFormat(.... //insert statement here.... ps.setTimestamp(1,fmt.format(mydate));
    Both keep submitting the date into Oracle as 16-Feb-2010 12:00:00 AM
    Anyway to get the current date and time? For example if I insert the data at 7:24.04 pm today it should show as 16-Feb-2010 07:24.04 PM in Oracle.

    sportsMarkr wrote:
    Date mydate = new Date(new java.util.Date().getTime());Please see the javadocs for java.sql.Date and note the part that says "...to zero"
    [http://java.sun.com/javase/6/docs/api/java/sql/Date.html]
    If you want a date and time then use java.sql.Timestamp.

  • I want to update date field in oracle table using database adaptor

    Hi Guys,
    I want to update date in oracle table field which is 'DATE' type , but i am getting following error.
    Pure SQL Exception.
    Pure SQL Execute of update crp3apps.IFACE_SO_DATE_CHANGES set PROCESSED_DATE=? where CTRL_ID=? failed. Caused by java.sql.SQLException: ORA-01830: date format picture ends before converting entire input string
    The Pure SQL option is for border use cases only and provides simple yet minimal functionality. Possibly try the "Perform an operation on a table" option instead.
    </summary>
    </part>
    - <part name="detail">
    <detail>
    ORA-01830: date format picture ends before converting entire input string
    </detail>
    i am formated the date using following code and assigned to one variable.
    ora:formatDate(ora:getCurrentDateTime(),'dd-MMM-yyyy hh:mm:ss ')
    this is update query
    update crp3apps.IFACE_SO_DATE_CHANGES set PROCESSED_DATE=#date where CTRL_ID=#id
    Please provide solution.
    regards
    janardhan

    The thing is that XSLT often doesn't deliver the functionality required when it comes to times.
    You suggest appening "Z" to the time but this means that the time is now in UTC time. What if the system from where the date is being converted is running in NZ using local time? Other systems that recieve the date (and correctly handle the time zone) will now have a time that is out by a number of hours.
    You often can't ignore the time zone (drop the 'Z') as if you send the time to a system it has to either assume the time is local to it (which may not be the case... the other system coudl be in a different time zone) or assume the time is UTC (I think crossfire does this by default).
    Typically can't just append a time zone (e.g. +11:00) either as many places have daylight savings so the value to appended is variable (you then need some way of determining what the value is... either Java Embedding or a Service).
    As you mention it does depend on the use case but in many circumstances using Jaba Embedding, not as suggested above but with the appropriate Java.util.Calendar classes, is the best way to handle date and time in BPEL. Even still you need to ascertain the format of times external to the system and ensure you parse them correctly.
    ANd even if you do all this you can still run into problems. I've seen a real world example where two systems which both handled time zones correctly and had previously been working together for quite a while, satrted reporting different times. It turns out that only one of them had had the most recent Java Time Zone patches applied and there had been a change in the dates for daylight savings here (Australia). Be warned!

  • Importing Date fields from Oracle always defaults to DT_DBDATETIME, and won't accept chages

    Hi
    I am trying to import date fields in an Oracle database in to SQL Server 2012, using SSIS. The package is using DT_DBTIMESTAMP type in the Data Flow, but this has the same range as SQL Server datetime, and it bombs out all the time.
    I have tried to change the type used to DT_DBDATE, but no matter what I do the data type on the input columns is readonly and will not change.
    Any help would be much appreciated
    Andy
    CRM 4, SQL Server and .Net developer using C#

    Hi Andy,
    From the Mapping of Integration Services Data Types to Database Data Types section of the document, we can get the detailed information about mapping the Oracle data types to Integration Services data types. To change the data type from DT_DBTIMESTAMP to
    DT_DBDATE, we can use the following two methods:
    Method 1:
    Right click on the Source component and click “Show Advanced Editor”.
    Switch to the “Input and Output Properties” tab, expand the XX Source Output node, and expand the Output Columns node.
    Click the target column, and change the DataType property to DT_DBDATE.
    Method 2:
    Add a Data Conversion component to the Data Flow Task
    Double click the Data Conversion component to open the Data Conversion Transformation Editor
    Select the target input column, and change the Data Type to database date [DT_DBDATE].
    If I have anything misunderstood, please feel free to let me know.
    Regards,
    Mike Yin
    If you have any feedback on our support, please click
    here
    Mike Yin
    TechNet Community Support

  • Decrypting an ecrypted data field in Oracle Database

    I am trying to decrypt an ecrypted data field (which is in
    Oracle Database)in Java. Can somebody help me since I am totally
    new to this.
    Thanks

    Ganesh,
    I am writing a program in Java where I am trying to query an
    Oracle Database table for UserID and Password since this
    password is encrypted in Oracle Table so I want to decrypt it in
    my program and then further pass it for the user.
    Thanks
    Anu

  • Why does Oracle SQL query returning a date field without the time component

    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!

    hokim wrote:
    Hi,
    I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
    I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
    On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
    On Oracle, I get the date field extracted as *26/APR/11*
    Why is the Oracle result in a different format & missing the time component?
    Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
    I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
    Plse help!http://edstevensdba.wordpress.com/category/nls_date_format/

Maybe you are looking for

  • Is it possible to build a second ssd in my MacBook?

    I've one SSD in my macbook (500GB) but it's not enought storage. Is it possible to place a second ssd in my macbook?

  • JScrollPane also move.Help!

    I add some JTextField in a Panel. and the panel is in a JScrollPane. i add keyListener for these textField, for example,KeyEvent.VK_UP, KeyEvent.VK_DOWN, the question is when i press up/down key,the JScrollPane also move up/down...(and perform before

  • CMR between EJBs in different JARs

    Hi, how could I manage CMR between EJBs in different JAR-files (different deplyoment descriptors as well) ? THX Tim

  • Program blocked in oci function

    Hello, When I read data from the database, everything works well. But when my program run some time, it blocked in oci function and can't work. Here is a stack from my code: GNU gdb 6.6 Copyright (C) 2006 Free Software Foundation, Inc. GDB is free so

  • Namespace not defined

    Hi When I was doing mapping I found out that I have not created a field in outbound data type. I went to my outbound data type and added the field. I saved it and tried to activate it. I got an error like this Namespace urn:ABC100 is not defined in t