You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Markus Daniel <ma...@synyx.de> on 2006/11/25 22:06:50 UTC

torque:datadump on oracle 10g

Hi all,
I try to dump data from an oracle database into a xml file.
For this purpose I try to use
Torque 3.2, Maven-Plugin, Goal: torque:datadump
Oracle JDBC Driver version - 9.0.2.0.0

corresponding row in the schema
<column name="aDate" required="true" type="TIMESTAMP"/>

trying to convert the oracle Timestamp into a String fails

[torque-data-dump] [ERROR] Exception fetching value aDate: Conversion to String failed

On the mysql the datadump works fine.

So I don't know if this is a bug or an oracle feature ;-)
or is there a missunderstanding from me ??

Any ideas?

Thanks a lot,
Markus


-- 
/**
 * Markus Daniel
 * Bachelor of Science in Computer Science
 * Synyx GmbH & Co. KG
 * Karlstr. 68
 * 76137 Karlsruhe
 * phone  +49(0)721 66 48 79 31
 * fax    +49(0)721 66 48 877
 * eMail  markus.daniel@synyx.de
 * www    http://www.synyx.de
 * irc    http://irc.synyx.de
 */


Re: torque:datadump on oracle 10g

Posted by Alvaro Coronel <al...@yahoo.com>.
I remember having problems with Oracle 9 using JDBC directly.
It was years ago, so I forgot the specifics (libraries used, etc.). What I do remember is that some software (the driver?) from oracle missreported the class of the results.

This happened with Date/Timestamp. I remember switching to Timestamp in the database hoping that this would fix it. It didn't, the results were then reported to be of another type (an oracle timestam) when they were in fact java timestamps.

We solved it the same quick way you did Markus :)

Best regards,
Álvaro



Markus Daniel <ma...@synyx.de> wrote: Hi Thomas, hi Greg,
thanks for your quick answer.

For future purpose I will have a look at
DdlUtils and on the torque-addons
both is very interesting...
but for now I quick fixed the TorqueDataDumpTask.java TableTool
like this:
        public String get(String columnName)
        {
            try
            {
                return (rs.getString(columnName));
            }
            catch (Exception se)
            {
                log("Exception fetching value " + columnName + ": "
                        + se.getMessage(), Project.MSG_ERR);
                if (getDatabaseDriver().contains("Oracle")) {
                    log("A Oracle DB.", Project.MSG_INFO);
                    log("Try to fix this.", Project.MSG_INFO);
                    int columnNo;
                    ResultSetMetaData rsMetaData;
                    try {
                        columnNo = rs.findColumn(columnName);
                        rsMetaData = rs.getMetaData();
                        if (rsMetaData.getColumnTypeName(columnNo).equalsIgnoreCase("timestamp")) {
                            log("The String representation of that timestamp : " +
                                    rs.getTimestamp(columnName).toString());
                            return rs.getTimestamp(columnName).toString();
                        } else {
                            log("Not able to fix column type : " + rsMetaData.getColumnTypeName(columnNo));
                        }
                    } catch (SQLException ex) {
                        log("Exception fetching value " + columnName + ": "
                        + ex.getMessage(), Project.MSG_ERR);
                    }
                }
            }
            return null;
        }

not very nice (specially getDatabaseDriver().contains("Oracle") in hope the driver name will always contains Oracle ;-(
) but it works fine and fixes the issue with oracle timestamp.
But after that I run into other problems with booleanchar and date/datetime because on the java side there is boolean in
oracle it gets to char represented with Y or N and the datadump doesn't know anything about the former boolean and gives
back an character (without ") so inserting this into mysql will fail...
I quick fixed this in a similar way, but this is to dark to tell ;-)

In future I will use the tool you mentioned.

Thanks a lot

regards,
Markus

Greg Monroe schrieb:
> FYI - There is also an XML import/export runtime add-on 
> for the 3.3 version that's in RC1 stage (very stable).
> 
> This lets you import and export from your application 
> rather than via ant/maven.  See:
> 
> http://torque-addons.sourceforge.net
> 
> 
> 
>> -----Original Message-----
>> From: Thomas Fischer [mailto:tfischer@apache.org] 
>> Sent: Sunday, November 26, 2006 5:23 AM
>> To: Apache Torque Users List
>> Subject: Re: torque:datadump on oracle 10g
>>
>> This is probably a Torque bug. The data import/export 
>> functionality for more exotic data types (I'm sad to say this 
>> als includes dates and
>> timestamps) does not work well and often it does not work at all.
>>
>> You might want to use dddlutils for that task. 
>> http://db.apache.org/ddlutils
>>
>>      Thomas
>>
>> On Sat, 25 Nov 2006, Markus Daniel wrote:
>>
>>> Hi all,
>>> I try to dump data from an oracle database into a xml file.
>>> For this purpose I try to use
>>> Torque 3.2, Maven-Plugin, Goal: torque:datadump Oracle JDBC Driver 
>>> version - 9.0.2.0.0
>>>
>>> corresponding row in the schema
>>> 
>>>
>>> trying to convert the oracle Timestamp into a String fails
>>>
>>> [torque-data-dump] [ERROR] Exception fetching value aDate: 
>> Conversion 
>>> to String failed
>>>
>>> On the mysql the datadump works fine.
>>>
>>> So I don't know if this is a bug or an oracle feature ;-) 
>> or is there 
>>> a missunderstanding from me ??
>>>
>>> Any ideas?
>>>
>>> Thanks a lot,
>>> Markus
>>>
>>>
>>> --
>>> /**
>>> * Markus Daniel
>>> * Bachelor of Science in Computer Science
>>> * Synyx GmbH & Co. KG
>>> * Karlstr. 68
>>> * 76137 Karlsruhe
>>> * phone  +49(0)721 66 48 79 31
>>> * fax    +49(0)721 66 48 877
>>> * eMail  markus.daniel@synyx.de
>>> * www    http://www.synyx.de
>>> * irc    http://irc.synyx.de
>>> */
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>
> 
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed.  If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you  please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 


-- 
/**
 * Markus Daniel
 * Bachelor of Science in Computer Science
 * Synyx GmbH & Co. KG
 * Karlstr. 68
 * 76137 Karlsruhe
 * phone  +49(0)721 66 48 79 31
 * fax    +49(0)721 66 48 877
 * eMail  markus.daniel@synyx.de
 * www    http://www.synyx.de
 * irc    http://irc.synyx.de
 */



 
---------------------------------
Access over 1 million songs - Yahoo! Music Unlimited.

Re: torque:datadump on oracle 10g

Posted by Markus Daniel <ma...@synyx.de>.
Hi Thomas, hi Greg,
thanks for your quick answer.

For future purpose I will have a look at
DdlUtils and on the torque-addons
both is very interesting...
but for now I quick fixed the TorqueDataDumpTask.java TableTool
like this:
        public String get(String columnName)
        {
            try
            {
                return (rs.getString(columnName));
            }
            catch (Exception se)
            {
                log("Exception fetching value " + columnName + ": "
                        + se.getMessage(), Project.MSG_ERR);
                if (getDatabaseDriver().contains("Oracle")) {
                    log("A Oracle DB.", Project.MSG_INFO);
                    log("Try to fix this.", Project.MSG_INFO);
                    int columnNo;
                    ResultSetMetaData rsMetaData;
                    try {
                        columnNo = rs.findColumn(columnName);
                        rsMetaData = rs.getMetaData();
                        if (rsMetaData.getColumnTypeName(columnNo).equalsIgnoreCase("timestamp")) {
                            log("The String representation of that timestamp : " +
                                    rs.getTimestamp(columnName).toString());
                            return rs.getTimestamp(columnName).toString();
                        } else {
                            log("Not able to fix column type : " + rsMetaData.getColumnTypeName(columnNo));
                        }
                    } catch (SQLException ex) {
                        log("Exception fetching value " + columnName + ": "
                        + ex.getMessage(), Project.MSG_ERR);
                    }
                }
            }
            return null;
        }

not very nice (specially getDatabaseDriver().contains("Oracle") in hope the driver name will always contains Oracle ;-(
) but it works fine and fixes the issue with oracle timestamp.
But after that I run into other problems with booleanchar and date/datetime because on the java side there is boolean in
oracle it gets to char represented with Y or N and the datadump doesn't know anything about the former boolean and gives
back an character (without ") so inserting this into mysql will fail...
I quick fixed this in a similar way, but this is to dark to tell ;-)

In future I will use the tool you mentioned.

Thanks a lot

regards,
Markus

Greg Monroe schrieb:
> FYI - There is also an XML import/export runtime add-on 
> for the 3.3 version that's in RC1 stage (very stable).
> 
> This lets you import and export from your application 
> rather than via ant/maven.  See:
> 
> http://torque-addons.sourceforge.net
> 
> 
> 
>> -----Original Message-----
>> From: Thomas Fischer [mailto:tfischer@apache.org] 
>> Sent: Sunday, November 26, 2006 5:23 AM
>> To: Apache Torque Users List
>> Subject: Re: torque:datadump on oracle 10g
>>
>> This is probably a Torque bug. The data import/export 
>> functionality for more exotic data types (I'm sad to say this 
>> als includes dates and
>> timestamps) does not work well and often it does not work at all.
>>
>> You might want to use dddlutils for that task. 
>> http://db.apache.org/ddlutils
>>
>>      Thomas
>>
>> On Sat, 25 Nov 2006, Markus Daniel wrote:
>>
>>> Hi all,
>>> I try to dump data from an oracle database into a xml file.
>>> For this purpose I try to use
>>> Torque 3.2, Maven-Plugin, Goal: torque:datadump Oracle JDBC Driver 
>>> version - 9.0.2.0.0
>>>
>>> corresponding row in the schema
>>> <column name="aDate" required="true" type="TIMESTAMP"/>
>>>
>>> trying to convert the oracle Timestamp into a String fails
>>>
>>> [torque-data-dump] [ERROR] Exception fetching value aDate: 
>> Conversion 
>>> to String failed
>>>
>>> On the mysql the datadump works fine.
>>>
>>> So I don't know if this is a bug or an oracle feature ;-) 
>> or is there 
>>> a missunderstanding from me ??
>>>
>>> Any ideas?
>>>
>>> Thanks a lot,
>>> Markus
>>>
>>>
>>> --
>>> /**
>>> * Markus Daniel
>>> * Bachelor of Science in Computer Science
>>> * Synyx GmbH & Co. KG
>>> * Karlstr. 68
>>> * 76137 Karlsruhe
>>> * phone  +49(0)721 66 48 79 31
>>> * fax    +49(0)721 66 48 877
>>> * eMail  markus.daniel@synyx.de
>>> * www    http://www.synyx.de
>>> * irc    http://irc.synyx.de
>>> */
>>>
>>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
>> For additional commands, e-mail: torque-user-help@db.apache.org
>>
>>
> 
> Duke CE Privacy Statement
> Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed.  If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you  please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited.
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 


-- 
/**
 * Markus Daniel
 * Bachelor of Science in Computer Science
 * Synyx GmbH & Co. KG
 * Karlstr. 68
 * 76137 Karlsruhe
 * phone  +49(0)721 66 48 79 31
 * fax    +49(0)721 66 48 877
 * eMail  markus.daniel@synyx.de
 * www    http://www.synyx.de
 * irc    http://irc.synyx.de
 */


RE: torque:datadump on oracle 10g

Posted by Greg Monroe <Gr...@DukeCE.com>.
FYI - There is also an XML import/export runtime add-on 
for the 3.3 version that's in RC1 stage (very stable).

This lets you import and export from your application 
rather than via ant/maven.  See:

http://torque-addons.sourceforge.net



> -----Original Message-----
> From: Thomas Fischer [mailto:tfischer@apache.org] 
> Sent: Sunday, November 26, 2006 5:23 AM
> To: Apache Torque Users List
> Subject: Re: torque:datadump on oracle 10g
> 
> This is probably a Torque bug. The data import/export 
> functionality for more exotic data types (I'm sad to say this 
> als includes dates and
> timestamps) does not work well and often it does not work at all.
> 
> You might want to use dddlutils for that task. 
> http://db.apache.org/ddlutils
> 
>      Thomas
> 
> On Sat, 25 Nov 2006, Markus Daniel wrote:
> 
> > Hi all,
> > I try to dump data from an oracle database into a xml file.
> > For this purpose I try to use
> > Torque 3.2, Maven-Plugin, Goal: torque:datadump Oracle JDBC Driver 
> > version - 9.0.2.0.0
> >
> > corresponding row in the schema
> > <column name="aDate" required="true" type="TIMESTAMP"/>
> >
> > trying to convert the oracle Timestamp into a String fails
> >
> > [torque-data-dump] [ERROR] Exception fetching value aDate: 
> Conversion 
> > to String failed
> >
> > On the mysql the datadump works fine.
> >
> > So I don't know if this is a bug or an oracle feature ;-) 
> or is there 
> > a missunderstanding from me ??
> >
> > Any ideas?
> >
> > Thanks a lot,
> > Markus
> >
> >
> > --
> > /**
> > * Markus Daniel
> > * Bachelor of Science in Computer Science
> > * Synyx GmbH & Co. KG
> > * Karlstr. 68
> > * 76137 Karlsruhe
> > * phone  +49(0)721 66 48 79 31
> > * fax    +49(0)721 66 48 877
> > * eMail  markus.daniel@synyx.de
> > * www    http://www.synyx.de
> > * irc    http://irc.synyx.de
> > */
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
> 
> 

Duke CE Privacy Statement
Please be advised that this e-mail and any files transmitted with it are confidential communication or may otherwise be privileged or confidential and are intended solely for the individual or entity to whom they are addressed.  If you are not the intended recipient you may not rely on the contents of this email or any attachments, and we ask that you  please not read, copy or retransmit this communication, but reply to the sender and destroy the email, its contents, and all copies thereof immediately.  Any unauthorized dissemination, distribution or copying of this communication is strictly prohibited.



---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: torque:datadump on oracle 10g

Posted by Thomas Fischer <tf...@apache.org>.
This is probably a Torque bug. The data import/export functionality for 
more exotic data types (I'm sad to say this als includes dates and 
timestamps) does not work well and often it does not work at all.

You might want to use dddlutils for that task. 
http://db.apache.org/ddlutils

     Thomas

On Sat, 25 Nov 2006, Markus Daniel wrote:

> Hi all,
> I try to dump data from an oracle database into a xml file.
> For this purpose I try to use
> Torque 3.2, Maven-Plugin, Goal: torque:datadump
> Oracle JDBC Driver version - 9.0.2.0.0
>
> corresponding row in the schema
> <column name="aDate" required="true" type="TIMESTAMP"/>
>
> trying to convert the oracle Timestamp into a String fails
>
> [torque-data-dump] [ERROR] Exception fetching value aDate: Conversion to String failed
>
> On the mysql the datadump works fine.
>
> So I don't know if this is a bug or an oracle feature ;-)
> or is there a missunderstanding from me ??
>
> Any ideas?
>
> Thanks a lot,
> Markus
>
>
> -- 
> /**
> * Markus Daniel
> * Bachelor of Science in Computer Science
> * Synyx GmbH & Co. KG
> * Karlstr. 68
> * 76137 Karlsruhe
> * phone  +49(0)721 66 48 79 31
> * fax    +49(0)721 66 48 877
> * eMail  markus.daniel@synyx.de
> * www    http://www.synyx.de
> * irc    http://irc.synyx.de
> */
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org