Context Variable from txt file - talend

I am trying to get Context (data connection) variable (Database input) from Txt file. This is the input of my txt file.
host;"xxx"
port;"xxx"
database;"xxx"
username;"xxx"
password;"xY"
database;"xx"
schema;"xY"
This is the query I am using to get table information "SELECT * FROM COMPANY". I have tried with Database. Table name also. But I am getting below error. "Exception in component tDBInput_1 (DataConnection_FromFile)
java.sql.SQLRecoverableException: IO Error: Invalid number format for port number"
Could you please suggest do I need to follow any other steps.

It seems that your port number context variable is typed as 'Integer'. Try to modify this and put it as a String in the 'Context' view.

Related

Azure Data Factory - Capture error details of a dataflow activity -> Store into a variable -> Assign this variable to a dataflow parameter

I have a data flow and my requirement is to capture the error details into a variable when it fails and assign this variable to a parameter in the next data flow. I tried to achieve this until the second stage(With help) as below, but I'm unable to get this variable assigned to a parameter in the next data flow. The error I get is - Expression cannot be parsed
What do I do later?
This parameter is assigned to a column in the data flow and I use this column to update the table in the dedicated pool with the relevant error message.
I tried to reproduce the same in my environment and I got the same error
The above scenario fails, because dataflow fails to parse ' ' and / in your error message.
To resolve above error,please follow below steps:
I just create the error fail1 with message containing a different character.
Go to set variable : Create a variable and added dynamic content to the value.
#replace(replace(string(activity('Fail1').output.message),pipeline().parameters.quote,'"'),'\','/')
Output:
Updated:
Parameter

operator does not exist: # timestamp without time zone

In a parameterized query issued from c# code to PostgreSQL 10.14 via dotConnect 7.7.832 .NET connector, I select either a parameter value or the local timestamp, if the parameter is NULL:
using (var cmd = new PgSqlCommand("select COALESCE(#eventTime, LOCALTIMESTAMP)", connection)
When executed, this statement throws the error in subject. If I comment out the corresponding parameter
cmd.Parameters.Add("#eventTime", PgSqlType.TimeStamp).Value = DateTime.Now;
and hardcode
using (var cmd = new PgSqlCommand("select COALESCE('11/6/2020 2:36:58 PM', LOCALTIMESTAMP)", connection)
or if I cast the parameter
using (var cmd = new PgSqlCommand("select COALESCE(cast(#eventTime as timestamp without time zone), LOCALTIMESTAMP)", connection)
then it works. Can anyone explain what # operator in the error is referring to and why the error?
In the case that doesn't work, your .Net connection library seems to be passing an SQL command containing a literal # to the database, rather than substituting it. The database assumes you are trying to use # as a user defined operator, as it doesn't know what else it could possibly be. But no such operator has been defined.
Why is it doing that? I have no idea. That is a question about your .Net connection library, not about PostgreSQL itself, so you might want to add tag.
The error message you get from the database should include the text of the query it received (as opposed to the text you think it was sent) and it is often useful to see that in situations like this. If that text is not present in the client's error message (some connection libraries do not faithfully pass this info along) you should be able to pull it directly from the PostgreSQL server's log file.

Database errors in Mirth channel

I want to use Mirth to connect to a database, then write a record to a table in that database.
The record contains a field "file_name", and this file name contain Date value, so a new file whose name would be like this:
temp_2015-08-10
This is what I passed to Mirth Destination SQL field:
INSERT INTO statutory_reports (str_est_id, str_type, str_create_date, str_created, str_record_status, str_file_path, str_file_name, str_created_by) VALUES (2, 'temp', CURDATE(), NOW(),'approved', 'C:/application/reports/temp reports/gumcad/', 'temp'+ ${date.get('yyyy-M-d hh:MM:ss')}, 'SHEP');
The problem is I get an error:
Database Writer error
ERROR MESSAGE: Failed to write to database
com.mirth.connect.connectors.jdbc.DatabaseDispatcherException: Failed to write to database
at com.mirth.connect.connectors.jdbc.DatabaseDispatcherQuery.send(DatabaseDispatcherQuery.java:143)
at com.mirth.connect.connectors.jdbc.DatabaseDispatcher.send(DatabaseDispatcher.java:103)
at com.mirth.connect.donkey.server.channel.DestinationConnector.handleSend(DestinationConnector.java:738)
at com.mirth.connect.donkey.server.channel.DestinationConnector.process(DestinationConnector.java:436)
at com.mirth.connect.donkey.server.channel.DestinationChain.call(DestinationChain.java:155)
at com.mirth.connect.donkey.server.channel.Channel.process(Channel.java:1656)
at com.mirth.connect.donkey.server.channel.Channel.dispatchRawMessage(Channel.java:1155)
at com.mirth.connect.donkey.server.channel.SourceConnector.dispatchRawMessage(SourceConnector.java:191)
at com.mirth.connect.donkey.server.channel.SourceConnector.dispatchRawMessage(SourceConnector.java:169)
at com.mirth.connect.connectors.jdbc.DatabaseReceiver.processRecord(DatabaseReceiver.java:200)
at com.mirth.connect.connectors.jdbc.DatabaseReceiver.processResultSet(DatabaseReceiver.java:160)
at com.mirth.connect.connectors.jdbc.DatabaseReceiver.poll(DatabaseReceiver.java:117)
at com.mirth.connect.donkey.server.channel.PollConnector$PollConnectorTask.run(PollConnector.java:131)
at java.util.TimerThread.mainLoop(Unknown Source)
at java.util.TimerThread.run(Unknown Source)
Caused by: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Truncated incorrect DOUBLE value: '2015-8-10 09:08:44'
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4206)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4140)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2597)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2758)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2826)
at com.mysql.jdbc.PreparedStatement.executeInternal(PreparedStatement.java:2082)
at com.mysql.jdbc.PreparedStatement.execute(PreparedStatement.java:1302)
at com.mirth.connect.connectors.jdbc.DatabaseDispatcherQuery.send(DatabaseDispatcherQuery.java:130)
The problem is the database is expecting yyyy-MM-dd for a DATE and you are providing yyyy-M-dd hh:mm:ss (note the month with one digit).
Format your date correctly with two digit month and remove the time part. If you want to provide the time, your database type should be DATETIME.
It's pretty descriptive: Truncated incorrect DOUBLE value: '2015-8-10 09:08:44'
The value (a date) is not of type double.
str_create_date or str_created is defined as double in your DB, but you are writing a Date type to it, which does not match.
If this is not the case, can you copy your DB schema here for validation?
vim to /opt/mirthconnect/conf/mirth.properties
under the database url copy this : jdbc:mysql://localhost/mirthdb?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
The new JavaMysql odbc seem to have this as a requirement, I think for security reasins

Exception while reading password from a file as a Talend context variable

I currently have a Talend job which reads from a context file and feeds into context variables. I have a field called ftppassword and store the hard coded password in the context file. I then have a context variable in the job and refer to that in my job.
With this setup my job runs fine but if I change the context file to contain a location to a password file instead of the hard coded password, I get the following exception:
Exception in component
tFTPConnection_1 com.enterprisedt.net.ftp.FTPException: 530 Login
incorrect. at
com.enterprisedt.net.ftp.FTPControlSocket.validateReply(FTPControlSocket
.java:11‌​79) at
com.enterprisedt.net.ftp.FTPClient.password(FTPClient.java:1844) at
com.enterprisedt.net.ftp.FTPClient.login(FTPClient.java:1766) –
**Edit - 2014-12-08 ****
Output of context parameters:
Implicit_Context_Context set key "ftphost" with value "ftp.host.com"
Implicit_Context_Context set key "ftpport" with value "21"
Implicit_Context_Context set key "ftpusername" with value "myuser"
Implicit_Context_Context set key "ftppassword" with value "/opt/password_files/DW/test1.password"
Implicit_Context_Context set key "ftpremotepath" with value "/Output/"
Implicit_Context_Context set key "ftpfilemask" with value "test_dn.zip"
Have also tried changing the data type of ftppassword to File and Password but had no luck with that.
The implicit tContextLoad option on the job is the equivalent of putting a tFileInputDelimited component at the start of your job with a schema of 2 columns: key and value. This is then read into a tContextLoad (hence the option name) to load the contexts in your job.
If your password file isn't in a key-value format then you can't use it this way.
The simplest option is to stick with the way you had it working before and use an implicit tContextLoad to load a delimited file with key-value pairs of your context variables.
Another option would be to no longer do this using the implicit tContextLoad option and instead to do it explicitly.
To do this you'd want to read in your password file using an appropriate connector such as a tFileInputDelimited. If you were reading in something that looked like /etc/passwd then you could split it on : to get:
username
password
user id
group id
user id info
home directory
shell location
You could then use a tMap to populate an output schema of:
key
value
You would then enter "ftppassword" as the key and connect the password value to the value column. You'll also want to filter this record set so you only get one password being set so you might want to use something like "ftpUser".equals(row1.username) in the expression filter of your output table in the tMap.
Then just connect this to a tContextLoad component and your job should load the password from /etc/passwd for the "ftpUser" user account.
If you are looking to pass a file path to another file containing the password so that you can split the dependencies and allow one file to contain all the other contexts for the job but to keep the password file elsewhere then instead you'd want to pass a context variable pointing to the password file but then you'd have to explicitly consume it in the job.
In this case you may have a context file that is loaded at run time with contexts such as ftpremotepath, ftphost and ftpfilemask that can be set directly in the file and then a ftpusercredentials context variable that is a file path to a separate credentials file.
This file could then be another delimited file containing key-value pairs of context name and value such as:
ftpuser,myuser
ftppasswd,p4ssw0rd
Then at the start of your job you would explicitly read this in using a tFileInputDelimited component with a schema of 2 columns: key and value. You could then connect this to a tContextLoad component and this will load the second set of context variables into memory as well.
You could then use these as normal by referring to them as context.ftpuser and context.ftppasswd.

What are the rules for a valid variable name in mirth?

I am trying to set up a transformer on a Database Reader to file writer channel. I am reading in a sql field called MRN which I would like to send to a variable called mrn. I added a step to a channel with a variable called tmp['MSH'] mapping to a variable called msg['MSH'] But mirth is giving me the error message:
The variable name contains invalid characters. Please enter a new variable name
What are the rules for a valid variable name in mirth?
tmp and msg are two built-in variables containing E4X mappings of the outbound template and inbound message, respectively. You would map, via a MessageBuilder step, from inbound to outbound with tmp['MSH'][...] = msg['MSH']... where ... refers to the appropriate sections. Essentially these are pre-populated javascript property arrays.
If you really want to create a variable for use in multiple places, the rules are alphanumeric plus '_', I believe.
In a MessageBuilder step, you could refer to a previously created variable with ${varname}.
I would recommend investing a little time in getting familiar with the basics. Documentation is wanting, to be sure, but this blog post series are a good place to start.