You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sqoop.apache.org by "lvchuanwen (JIRA)" <ji...@apache.org> on 2016/01/05 03:49:39 UTC

[jira] [Resolved] (SQOOP-2661) Improved sqoop extraction of Oracle 11 timestamp data type exception problem

     [ https://issues.apache.org/jira/browse/SQOOP-2661?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

lvchuanwen resolved SQOOP-2661.
-------------------------------
    Resolution: Fixed

> Improved sqoop extraction of Oracle 11 timestamp data type exception problem
> ----------------------------------------------------------------------------
>
>                 Key: SQOOP-2661
>                 URL: https://issues.apache.org/jira/browse/SQOOP-2661
>             Project: Sqoop
>          Issue Type: Improvement
>          Components: connectors/generic
>    Affects Versions: 1.99.6
>         Environment: oracle 11g 
> sqoop1.99.6
> ojdbc6.jar
>            Reporter: lvchuanwen
>             Fix For: 1.99.7
>
>
> When I use sqoop to extract the timestamp Oracle type data, I must add -Doracle.jdbc.J2EE13Compliant=true to the /sqoop/server/bin/catalina.sh script, sqoop can work properly.
> If the -Doracle.jdbc.J2EE13Compliant=true is not set due to carelessness
> This error will occur
> By: java.lang.ClassCastException: oracle.sql.TIMESTAMP cannot be cast to java.sql.Timestamp Caused
> Org.apache.sqoop.connector.jdbc.GenericJdbcExtractor.extract at (GenericJdbcExtractor.java:79)
> Org.apache.sqoop.connector.jdbc.GenericJdbcExtractor.extract at (GenericJdbcExtractor.java:38)
> Org.apache.sqoop.job.mr.SqoopMapper.run at (SqoopMapper.java:95)
> 7 more
> I think can use API  resultSet.getTimestamp(i + 1) instead of (java.sql.Timestamp)resultSet.getObject(i + 1); to avoid
> This type converts exception .
> resultSet.getDate(i + 1), resultSet.getTime(i+1) alse can instead of (java.sql.Date)resultSet.getObject(i + 1), (java.sql.Time)resultSet.getObject(i + 1)
> {code:title=GenericJdbcExtractor.java|borderStyle=solid}
>  switch (schemaColumn.getType()) {
>           case DATE:
>             // convert the sql date to JODA time as prescribed the Sqoop IDF spec
>             array[i] = LocalDate.fromDateFields((java.sql.Date)resultSet.getObject(i + 1));
>             break;
>           case DATE_TIME:
>             // convert the sql date time to JODA time as prescribed the Sqoop IDF spec
>             array[i] = LocalDateTime.fromDateFields((java.sql.Timestamp)resultSet.getObject(i + 1));
>             break;
>           case TIME:
>             // convert the sql time to JODA time as prescribed the Sqoop IDF spec
>             array[i] = LocalTime.fromDateFields((java.sql.Time)resultSet.getObject(i + 1));
>             break;
>           default:
>             //for anything else
>             array[i] = resultSet.getObject(i + 1);
>           }
> {code}
> reference:http://docs.oracle.com/cd/B28359_01/java.111/b31224/datacc.htm#i1024324



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)