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
Related
I am using C++ Builder 10.2.3 (Rad Studio Tokyo 10.2.3) with Interbase 2017
I need to create users at runtime for my users registration.
If I create the Query at runtime, in that case there is no parameter, it works. But this creates problems with MBCS characters I will explain later.
If I create the Query at design-time with parameters and try to set the parameters at runtime. I am getting the error message below:
[Application: ]
[Error] -104 335544569 Dynamic SQL Error
SQL error code = -104
Token unknown - line 2, char 14
?
The query I am using is below:
CREATE USER myuser
SET PASSWORD :mypass,
FIRST NAME :myfirstname,
LAST NAME :myname;
I replace the first line of the Query at runtime, so there is no character. And after all, Interbase cannot handle MBCS characters in USERNAME.
I need to use a Query with parameters because my application handles multi-bytes characters (MBCS), like Chinese and Japanese. And this is the only option to be sure of a proper conversion to UTF8 in Interbase. Because if the conversion of MBCS characters is not done, I cannot backup and restore my database. When I try to restore with MBCS characters in First and last name, I am getting an error message that Interbase cannot transliterate between character sets.
Base on the error message, it appears to me that it does not recognize the Query parameters.
I tried with both "TIBQuery" and "TIBSQL". Same issue. Impossible to use also Store procedures. Does not recognize the create word.
So, how to fix that ?
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.
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.
Am facing Issue with date format while running Informatica mapping with database db2.
Effective date coming from input is "2020-03-17 00:00:00.000000000".
But on passing to stored procedure I called in mapping it is reading it in format "03/17/2020 00:00:00.000000000" which causes Informatica to throw the following exception into the Informatica session logs.
Severity Timestamp Node Thread Message Code Message
ERROR 4/2/2020 11:53:34 AM ecrmqetl TRANSF_1_1_1 CMN_1022 Database driver error...
CMN_1022 [ [IBM][CLI Driver][DB2/AIX64] SQL0180N The syntax of the string representation of a datetime value is incorrect. SQLSTATE=22007 sqlstate = 22007
Database driver error...
Function Name : ExecuteSP
Native error code = -180
Database driver error...
Function Name : ExecuteSP
Native error code = -180]
Any help is much appreciated.
Try to convert input string into expected date type format .
I am trying to convert the following SQL Server query to Postgresql
select CAST(CAST('<IncludeSettle/><StartTime value="2019-03-26 08:45:48.780"></StartTime>' as XML).value('(//StartTime/#value)[1]', 'datetime') AS varchar(40)) + ''')';
I have tried converting it to below and got back following error.
select unnest(xpath('//StartTime/#value', xmlparse(document '<IncludeSettle/><StartTime value="2019-03-26 08:45:48.780"></StartTime>')))
Error:
ERROR: invalid XML document
DETAIL: line 1: Extra content at the end of the document
<IncludeSettle/><StartTime value="2010-03-26 08:45:48.780"></StartTim
^
SQL state: 2200M
As a hack, I had made the following change to make it work.
select unnest(xpath('//StartTime/#value', xmlparse(document '<tempzz>'||'<IncludeSettle/><StartTime value="2019-03-26 08:45:48.780"></StartTime>'||'</tempzz>')))
Output for Postgresql:
2019-03-26 08:45:48.780
I am looking for a better solution. Any help really appreciated.
You can process that by adding the dummy root as you did. The value is already formatted as an ISO timestamp, so you can simply cast it to a timestamp:
But as there is no direct cast from xml to timestamp you need to cast the result of the xpath() to text first.
with data (input) as (
values ('<IncludeSettle/><StartTime value="2019-03-26 08:45:48.780"></StartTime>')
)
select (xpath('//StartTime/#value', ('<dummy_root>'||input||'</dummy_root>')::xml))[1]::text::timestamp
from data