简体   繁体   中英

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM