基本上,我是欢乐连接的新手。请给我一些建议。
当我在Run Post-Process脚本上使用类似的东西时:
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/mirth','XYZ','XYZ');
a =$('his_user_id');
responseStatus=Response.getStatus();
loger.info(responseStatus);
if(responseStatus == SENT) {
var result = dbConn.executeUpdate("UPDATE his_user SET status =0 where id"+a);
return result;
}
}
finally {
if (dbConn) {
dbConn.close();
}
}
我收到以下错误:
SourceSOURCE CODE:
53:var dbConn; 54:55:尝试{56:
dbConn = DatabaseConnectionFactory.createDatabaseConnection
( 'com.mysql.jdbc.Driver', 'JDBC:MySQL的://本地主机:3306 /欢笑', 'root','root'); 57:a = $('his_user_id'); 58: responseStatus = Response.getStatus(); 59: loger.info(responseStatus); 60:if(responseStatus == SENT)61:
{62:行号:58DETAILS:
Java类“com.mirth.connect.userutil.Response”有
没有名为“getStatus”的公共实例字段或方法。在 0462ff2d-8942-4898-9afb-802bfe68a63d:58
(doScript)at 0462ff2d-8942-4898-9afb-802bfe68a63d:74
这是我在db writer中的预处理脚本
var dbConn;
try {
dbConn = DatabaseConnectionFactory.createDatabaseConnection('com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/mirth','root','root');
var result = dbConn.executeCachedQuery("SELECT his_user.Id AS his_user_Id, his_user.His_username AS his_user_His_username, his_user.His_useraddress AS his_user_His_useraddress, his_user.status AS his_user_status FROM his_user where his_user.status='1'");
return result;
}
finally {
if (dbConn) {
dbConn.close();
}
}
答案 0 :(得分:0)
将dbConn改为使用它,它应该可以工作......
importPackage(java.sql中);
var dbConn = java.sql.DriverManager.getConnection(' jdbc:jtds:sqlserver:// localhost:1433 / dbname',' user',' pass&# 39);
如果您不想更改dbConn,可以通过替换" dbConn.prepareStatement"来绕过它。使用" dbConn.getConnection()。prepareStatement"。如果这不起作用,您可能还需要包含" importPackage(java.sql);"在变压器代码的开头。