简体   繁体   English

测试数据库连接在Mirth的出站数据库连接器中使用Javascript

[英]Testing database connection Using Javascript in outbound database connector in Mirth

I have database handle in channelMap (for 1 connection for all messages) and I reuse the connection for all messages. 我在channelMap中具有数据库句柄(用于所有消息的1个连接),并且对所有消息重用该连接。 Now, before performing inserts (to a MySQL database), I want to test if the connection still exists. 现在,在执行插入(到MySQL数据库)之前,我想测试连接是否仍然存在。 How do I perform this test? 如何执行此测试?

A crude way is to grab the connection and run a simple query (a simple SELECT or SHOW query would do) and catch the exception. 一种粗略的方法是获取连接并运行简单查询(可以执行简单的SELECT或SHOW查询)并捕获异常。

I think this is all based on JTDS, so you should be able to use Connection.closed which will return true if the connection is closed and false if it is open. 认为这都是基于JTDS的,因此您应该能够使用Connection.closed,如果关闭连接将返回true,如果打开则返回false。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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