<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    Using the JDBC 8i, 9iR1, Oracle's DATE datatype is mapped to the "java.sql.Timestamp" class. However, the new "ojdbc14.jar" driver maps DATE to "java.sql.Date", and "java.sql.Date" only holds a date (without a time), whereas "java.sql.Timestamp" holds both a date and a time.




    Subject: JDBC 920x Date/TimeStamp mapping
    Type: BULLETIN
    Status: UNDER_EDIT
    Content Type: TEXT/PLAIN
    Creation Date: 29-JUL-2003
    Last Revision Date: 04-OCT-2004


    PURPOSE
    -------
       Clarify the use of oracle.jdbc.V8Compatible property flag
     
    SCOPE & APPLICATION
    -------------------
    JDBC 920x Date/TimeStamp mapping is different from JDBC 8i, 9iR1.
    <TITLE FOR MAIN ARTICLE TEXT>
    -----------------------------
    Summary of  features afftected by oracle.jdbc.V8Compatible.
     
    As of 9.2.0.1.0 Oracle realigned its DATE type with the java.sql.Types.DATE type.
    Prior to this
    java.sql.DATE and  java.sql.TIMESTAMP were mapped to java.sql.Types.TIMESTAMP.
     
    This mapping change applies to JDBC default mapping (i.e when getObject() is
    used for Date column.
     
    example:
    select sysdate from dual;
    ...
    while (rset.next ())  {
    System.out.println("getObject for sysdate  : " +
    rset.getObject(1).getClass().getName());
    System.out.println("getDate for sysdate :" +
    rset.getDate(1).getClass().getName());
    System.out.println("getTimetamp for sysdate :" +
    rset.getTimestamp(1).getClass().getName());
    }
     
    Prior to 9201, this will return
    getObject for sysdate  : java.sql.Timestamp      <<<<
    getDate for sysdate :java.sql.Date
    getTimetamp for sysdate :java.sql.Timestamp
     
    As of 9201 onward the following will be returned
     
    getObject for sysdate  : java.sql.Date        <<<<<
    getDate for sysdate :java.sql.Date            >> no change
    getTimetamp for sysdate :java.sql.Timestamp   >> no change
     
     
     
    Note: java.sql.Date has no time portion whereas java.sql.Timestamp does.
     
     
    With this change in Datatype mapping, some application will fail and/or generate
    incorrect results when JDBC driver is upgraded from 8i/ 9iR1 to 920x JBDC driver.
    To maintain compatibility and keep applications working after upgrade, a compatibility flag was
    Provided.  Developers now have some options:
     
    1>
    Use oracle.jdbc.V8Compatible flag.
     
    JDBC Driver does not detect database version by default.
    To change the compatibility flag for handling TIMESTAMP datatypes,
    connection property 'oracle.jdbc.V8Compatible' can be set to
    'true' and the driver behaves as it behaved in 8i, 901x, 9200
    (with respect to TIMESTAMPs).
    By default the flag is set to 'false'. In OracleConnection constructor
    the driver obtains the server version and set the compatibility flag
    Appropriately.
     
    java.util.Properties prop = new java.util.Properties ();
    prop.put ("oracle.jdbc.V8Compatible", "true");
    prop.put ("user", "scott");
    prop.put ("password", "tiger");
    String url ="jdbc:oracle:thin:@host:port:sid";
    Connection conn = DriverManager.getConnection (url,prop);
     
     
     
    With JDBC 10.1.0.x, in instead of the connection property, the following system
    property can be useed
    java -Doracle.jdbc.V8Compatible=true .....
     
     
     
    Note: This flag is a client only flag that governs the Timestamp and Date mapping.
    It does not affect any Database feature.
     
     
     
    2> use set/getDate and set/getTimestamp   when dealing with Date and TimeStamp column datatype accordingly.
    9i server  supports both Date and Timestamp column types
     
    DATE is mapped to  java.sql.Date and TIMESTAMP is mapped to java.sql.Timestamp
     
    I> using setTimestamp
     
    PreparedStatement pstmt = conn.prepareStatement(
    "SELECT count(*) from  tstable where tscol between ? and ?");
    // tscol of type Timetamp (or it can be Date)
     
    String s = new String("2003-01-14 10:00:00.000000000");
    Timestamp ts1 = Timestamp.valueOf(s);
    pstmt.setTimestamp(1, ts1); // Timestamp
     
    String s2 = new String("2003-01-16 10:00:00.000000000");
    Timestamp ts2 = Timestamp.valueOf(s2);
    pstmt.setTimestamp(2, ts2); // Timestamp
    ...
     
     
    II>using setDate
     
    PreparedStatement pstmt = conn.prepareStatement(
    "SELECT count(*) from  tstable where datecol between ? and ?");
    // datecole of type Date
     
    /*
    pstmt.setDate(1,new java.sql.Date(System.currentTimeMillis()));
    pstmt.setDate(2,new java.sql.Date(System.currentTimeMillis()));
    */
     
    SimpleDateFormat start_dt_in1 = new SimpleDateFormat("2002-09-18 00:00:00");
    SimpleDateFormat start_dt_in2 = new SimpleDateFormat("2003-09-18 00:00:00");
    pstmt.setDate(1,start_dt_in1);
    pstmt.setDate(2,start_dt_in2);
     
     
     
    Summary of  features afftected by oracle.jdbc.V8Compatible.
     
    Is backward compatible (with oracle.jdbc.V8Compatible)?
    
     
     
    * Examples:
    ..
    The following will fail   when using JDBC 9iR1, 9iR2 connecting 817 server since the
    817 did not support Timestamp
     
     
    Connection conn = DriverManager.getConnection(url, "scott",  "tiger");
    // Prepare a statement to cleanup the emp table
    Statement  stmt = conn.createStatement();
    try {
    stmt.execute("delete from EMP where EMPNO = 1");
    } catch (SQLException e) {
    }
    try {
    stmt.execute("INSERT INTO EMP (EMPNO, ENAME, HIREDATE) VALUES (1, 
    'ALI', {ts '2003-04-14 14:19:24.94'})");
    } catch (SQLException e) {
    e.printStackTrace();
    }
     
    Error : Exception in thread "main" java.sql.SQLException: ORA-00904: invalid column name
     
    Solution you need
    1> fix for Bug 2640192 (included in 9204)
    2> oracle.jdbc.V8Compatible", "true"
     
     
     
    In earlier versions of JDBC drivers  SQL FUNCTION "TS" was mapped to "to_date" .   So, the query
     
    select {ts '2002-10-18 18:02:00'} from dual;
    was translated by JDBC to,
    select TO_DATE ('2002-10-18 18:02:00',  'YYYY-MM-DD HH24:MI:SS') from dual;
     
     
    With 9i Timestamp is supported in the database and also by 9203 JDBC Drivers.
    So the query
     
    select {ts '2002-10-18 18:02:00'} from dual;
     
    is now translated  by JDBC to
     
    select TO_TIMESTAMP('2002-10-18 18:02:00', 'YYYY-MM-DD HH24:MI:.SS.FF') from dual;
     
     
    Known issues:  There is some performances issue when set/getTimestamp
    Bug 3037615
    Bug 2770935
    These bugs are very likely duplicate.
     
     
    The following code will no longer work with 9203+ unless V8 flag is set to true
     
    Timestamp start_dt_in = Timestamp.valueOf("2002-09-18 00:00:00");
    Timestamp now_period_start_dt ;
    PreparedStatement stmt = null;
    ResultSet rs = null;
     
    System.out.println("start_dt_in="+  start_dt_in );
     
    try {
    stmt = conn.prepareStatement( "SELECT TRUNC(?) FROM DUAL" );
    stmt.setTimestamp( 1, start_dt_in );
    rs = (OracleResultSet) stmt.executeQuery();
    if ( rs.next() ) {
    now_period_start_dt = rs.getTimestamp( 1 );
    System.out.println("Curr Period Start="+  now_period_start_dt );
    }
     
     
    will generate
    Exception in thread "main" java.sql.SQLException:
    ORA-932: inconsistent datatypes
     
     
    Reason : trunc ( )  supports Date columns and does not support  Timestamp  (this is an RDBMS issue).
    So, you need to set the V8 flag to true
     
    Another bug that changed the Date/Timetamp mapping is  2428427 to comly with
    J2EE 1.3 CTS.  This was fixed in 9014 and it specific to classesdmx*.zip/jar
    (the *dms* jar filed mainly used by iAS/OC4J).  These *dms* jar files, by the
    default value for oracle.jdbc.J2EE13Compliant  is true.  in classes111.zip
    classes12.jar and ojdbc14.jar/zip the default is false.
     
    One can toggel this flag  true/false by
     
    java -Doracle.jdbc.J2EE13Compliant=true|false
     
     
    example of of sample runs:
     
    query used :"select sysdate from dual"
    classes12dms.jar used.
     
     
    Driver Version      Object Type
    ==============      ===========
    9.0.1.3.0         java.sql.Timestamp >> fix for 2428427 NOT included
    9.0.1.4.0         java.sql.Date   >> fix for 2428427 INCLUDED
    9.0.1.5.0         java.sql.Date   >> fix for 2428427 INCLUDE
     
    In JDBC 9014+ ,to keep older (9013) behavior  simply run the application with
     
     
    $java -Doracle.jdbc.J2EE13Compliant=false .....
     
     
    However please note that J2EE 1.3 CTS require that Date to mapped to
    java.sql.Date.
    

    只有注冊用戶登錄后才能發表評論。


    網站導航:
     
    主站蜘蛛池模板: 亚洲日韩国产AV无码无码精品| 中文字幕精品无码亚洲字| 亚洲一区二区中文| 久久99热精品免费观看动漫| 国产成人亚洲精品影院| 一级毛片完整版免费播放一区| 亚洲综合精品网站| 国产精品九九久久免费视频| 国产亚洲精品成人a v小说| 亚洲精品国产日韩无码AV永久免费网 | 一级毛片**免费看试看20分钟| 免费播放特黄特色毛片| 免费一级特黄特色大片| 伊伊人成亚洲综合人网7777| 东方aⅴ免费观看久久av| 亚洲av日韩av天堂影片精品| 亚州免费一级毛片| 亚洲国产日韩视频观看| 国产精品视频免费一区二区三区| 国产天堂亚洲精品| 国产精一品亚洲二区在线播放| 无码日韩精品一区二区三区免费| 久久久亚洲AV波多野结衣| 四虎永久在线精品免费网址| 亚洲AV日韩AV一区二区三曲| 亚洲国模精品一区| 一级毛片不卡片免费观看| 精品亚洲456在线播放| 亚洲午夜福利精品无码| 毛片无码免费无码播放| 狠狠色伊人亚洲综合网站色| 亚洲av区一区二区三| 国产精品免费福利久久| 天堂亚洲国产中文在线| 国产乱辈通伦影片在线播放亚洲 | 免费无码专区毛片高潮喷水| 亚洲国产精品一区二区久久hs | 免费看男女下面日出水视频| a毛片在线免费观看| 伊人久久亚洲综合影院首页| av在线亚洲欧洲日产一区二区|