One Star

Mapping Document datatype of Talend to Postgresqloutput

I am getting this error message when i try to map my Document data type to XML in Postgresqlputput.
The error says "The Method setDocument(int,Document) is undefined for the type PreparedStatement.
7 REPLIES
Seventeen Stars

Re: Mapping Document datatype of Talend to Postgresqloutput

A database could only store a document as text content or in case of XML databases they parse the content.
PostgreSQL cannot parse the XML content and therefore you have to save it as text content. 
I would convert the document into a String ans persists this.
One Star

Re: Mapping Document datatype of Talend to Postgresqloutput

How do I convert the xml to string? Should i have to take the individual tag values and save them as string?
Seventeen Stars

Re: Mapping Document datatype of Talend to Postgresqloutput

Use this expression:
String.valueOf(row1.my_document)

row1 and my_document must be changed to the names you have in your job.
One Star

Re: Mapping Document datatype of Talend to Postgresqloutput

Hi
I have a job that reads data from xml files in a specfic folder one by one and store them into a postgresql db. 
Whenever i get any kind of system error(for eg: Database does not exist), the whole job fails and the next file is not picked up. My requirement is that in case there is an error in a file, my tLogCatcher should log it  and the job should pick the next xml file and proceed with inserting into the postgresql db. 
Is there a way to do this? All other user defined errors i am able to handle. Only the system errors are creating this problem.Any help on this would be much appreciated.

Thanks
Sri
Seventeen Stars

Re: Mapping Document datatype of Talend to Postgresqloutput

For sure. I suggest you add to the inout folder an backup folder and move every correctly imported file into the backup folder. 
Build a job (import_steering) which is fairly simple and iterates through the files (with filters to pickup only the right files).
Build another job (called import_worker) which import exactly one file. This worker job will be called from the  import_steering job with tRunJob and the steering job hands over the file path from the tFileList component as context parameter (e.g. context.currentFile) to the worker job. When the worker job has finished importing a file the file will be moved into the backup (do this in the worker job) or move it into an error dir if the file is damaged.
This way you cam easily text your import job (to give the file name set the context var currentFile as prompt and set the type File (which is technical a String but provide a nice file chooser).
 
One Star

Re: Mapping Document datatype of Talend to Postgresqloutput

Thank you for the reply. I tried this parent child execution. When the first file is in the expected format and the second file has a problem the job gets executed as expected. The problem comes when the first file is erroneous. The second file also takes the same path as the first file though it is in the correct format. Once the job goes through the tlogCatcher section the next iterations also go only via the tlogCatcher, Any idea why this happens?
One Star

Re: Mapping Document datatype of Talend to Postgresqloutput

I am attaching a screen shot of my child job as well as the logcatcher section. I have wantedly created an error in tPostgresqlOutput_3. But the expected path to be taken is the one which has tPostgresqloutput_2. I have highligted 2 sections of the job which has the text "Starting". i am confused as why this portion is getting executed. Can you please throw some light on how to refine my job hoping that would resolve my issue. Thanks.