[ 
https://issues.apache.org/jira/browse/SQOOP-2661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14992891#comment-14992891
 ] 

lvchuanwen commented on SQOOP-2661:
-----------------------------------

{noformat}
Note:
The ResultSet.getObject method returns java.sql.Timestamp for the TIMESTAMP SQL 
type, only when the connection property oracle.jdbc.J2EE13Compliant is set to 
TRUE. This property has to be set when the connection is obtained. If this 
connection property is not set or if it is set after the connection is 
obtained, then the ResultSet.getObject method returns oracle.sql.TIMESTAMP for 
the TIMESTAMP SQL type.
The oracle.jdbc.J2EE13Compliant connection property can also be set without 
changing the code in the following ways:

Including the ojdbc5dms.jar or ojdbc6dms.jar files in the CLASSPATH. These 
files set oracle.jdbc.J2EE13Compliant to TRUE by default. These are specific to 
the Oracle Application Server release and are not available as part of the 
general JDBC release. They are located in $ORACLE_HOME/jdbc/lib.

Setting the system property by calling the java command with the flag 
-Doracle.jdbc.J2EE13Compliant=true. For example,

java -Doracle.jdbc.J2EE13Compliant=true ...
{noformat}

> 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
>            Reporter: lvchuanwen
>             Fix For: 1.99.7
>
>
> When we use sqoop to extract the timestamp Oracle type data, we 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
>  we 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)

Reply via email to