I'm trying to make use of Windows Search by using java Jacob library. but I'm having troubles to specify the maxRecords option to limit the number of rows get back.
I'm trying to do it by using this line:
Dispatch.put(connection, "MaxRecords", new Variant(10));
After setting up the connection:
connection = new Dispatch("ADODB.Connection");
Dispatch.call(connection, "Open", "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';");
//-------> error in the following line <-------
Dispatch.put(connection, "MaxRecords", new Variant(10));
results = Dispatch.call(connection, "Execute",
"SELECT System.ItemName, System.DateModified " +
"FROM SystemIndex " +
"WHERE Directory='file:C:/my/folder/path' AND Contains('a')").toDispatch();
while (!Dispatch.get(results, "EOF").getBoolean()) {
Dispatch fields = Dispatch.get(results, "Fields").toDispatch();
String filename = Dispatch.get(Dispatch.call(fields, "Item", new Integer(0)).toDispatch(), "Value").toString();
String filedate = Dispatch.get(Dispatch.call(fields, "Item", new Integer(1)).toDispatch(), "Value").toString();
list.put(filename, filedate);
Dispatch.call(results, "MoveNext");
}
What am I doing wrong?
There's no error on compilation but on executing I get this message:
com.jacob.com.ComFailException: A COM exception has been encountered:
At Invoke of: MaxRecords
Description: 80020007 / No named arguments.
...
Internal Server Error (500) - The server encountered an unexpected condition which prevented it from fulfilling the request
And this one when accessing through my restful by URL:
Internal Server Error
The server encountered an unexpected condition which prevented it from fulfilling the request
You can get technical details here.
Please continue your visit at our home page.
Everything works fine without that line.
According to the docs, the Connection object does not have a MaxRecords property. I think you'd want to set MaxRecords on a RecordSet object.
EDIT:
I haven't tried these, but would try along the following lines:
connection = new Dispatch("ADODB.Connection");
Dispatch.call(connection, "Open", "Provider=Search.CollatorDSO;Extended Properties='Application=Windows';");
String sql = "SELECT System.ItemName, System.DateModified " +
"FROM SystemIndex " +
"WHERE Directory='file:C:/my/folder/path' AND Contains('a')"
recordSet = new Dispatch("ADODB.Recordset");
Dispatch.put(recordSet, "MaxRecords", new Variant(10));
Dispatch.call(recordSet, "Open", sql, connection);
while (!Dispatch.get(recordSet, "EOF").getBoolean()) {
...
}
Related
my code here:
function MsgReceivedInPastHourchannelId,connectorID, status) {
var client = new com.mirth.connect.client.core.Client('https://127.0.0.1:443/');
try{
var loginStatus = client.login('userID', 'psw');
} catch(ex) {
client.close();
throw 'Unable to log-on the server , Error: ' + ex.message;
}
var filter = new com.mirth.connect.model.filters.MessageFilter;
var calendar = java.util.Calendar;
var startDate = new calendar.getInstance();
var endDate = new calendar.getInstance();
..
.. logic to set start/end date
..
filter.setStartDate(startDate);
filter.setEndDate(endDate);
var statuses = new java.util.HashSet();
var Status = com.mirth.connect.donkey.model.message.Status;
var list = Lists.list().append(connectorID);
var metricStatus = Status.SENT;
statuses.add(metricStatus);
filter.setStatuses(statuses);
filter.setIncludedMetaDataIds(list) ;
var nCount =client.getMessageCount(channelId, filter);
client.close();
return nCount
}
reference :
Mirth getMessageCount using Javascript not working
Mostly it works fine, but it randomly throw exception at line number 218, this is
var client = new com.mirth.connect.client.core.Client('https://127.0.0.1:443/')
anyone have experience or solution to get rid of such error:
[2021-06-30 02:00:02,000] ERROR (com.mirth.connect.connectors.js.JavaScriptDispatcher:193):
Error evaluating JavaScript Writer (JavaScript Writer "Submit Hx channel status to DataDog" on channel 1xxxxxxxxxxxxxxxx4).
com.mirth.connect.server.MirthJavascriptTransformerException: CHANNEL:
ChannelStatus-Poller-CountCONNECTOR:
Submit Hxchannel status to DataDogSCRIPT SOURCE:
JavaScript WriterSOURCE CODE:
218: var client = new com.mirth.connect.client.core.Client('https://127.0.0.1:443/') 221: // log on to the server222:
try{LINE NUMBER: 218 DETAILS:
Wrapped java.lang.IllegalStateException: zip file closed
at a7fa25a9-af95-4410-bb4f-f4f08ae0badb:218 (MsgReceivedInPastHour)
at a7fa25a9-af95-4410-bb4f-f4f08ae0badb:1013 (doScript)
at a7fa25a9-af95-4410-bb4f-f4f08ae0badb:1033
at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:184)
at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:122)
at com.mirth.connect.server.util.javascript.JavaScriptTask.call(JavaScriptTask.java:113)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)Caused by: java.lang.IllegalStateException: zip file closed
at java.util.zip.ZipFile.ensureOpen(ZipFile.java:686)
at java.util.zip.ZipFile.access$200(ZipFile.java:60)
at java.util.zip.ZipFile$ZipEntryIterator.hasNext(ZipFile.java:508)
at java.util.zip.ZipFile$ZipEntryIterator.hasMoreElements(ZipFile.java:503)
at java.util.jar.JarFile$JarEntryIterator.hasNext(JarFile.java:253)
at java.util.jar.JarFile$JarEntryIterator.hasMoreElements(JarFile.java:262)
at org.reflections.vfs.ZipDir$1$1.computeNext(ZipDir.java:30)
at org.reflections.vfs.ZipDir$1$1.computeNext(ZipDir.java:26)
at com.google.common.collect.AbstractIterator.tryToComputeNext(AbstractIterator.java:141)
at com.google.common.collect.AbstractIterator.hasNext(AbstractIterator.java:136)
at org.reflections.Reflections.scan(Reflections.java:240)
at org.reflections.Reflections.scan(Reflections.java:204)
at org.reflections.Reflections.<init>(Reflections.java:129)
at org.reflections.Reflections.<init>(Reflections.java:170)
at org.reflections.Reflections.<init>(Reflections.java:143)
at com.mirth.connect.client.core.Client.<init>(Client.java:176)
at com.mirth.connect.client.core.Client.<init>(Client.java:143)
at sun.reflect.GeneratedConstructorAccessor159.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.mozilla.javascript.MemberBox.newInstance(MemberBox.java:159)
at org.mozilla.javascript.NativeJavaClass.constructInternal(NativeJavaClass.java:266)
at org.mozilla.javascript.NativeJavaClass.constructSpecific(NativeJavaClass.java:205)
at org.mozilla.javascript.NativeJavaClass.construct(NativeJavaClass.java:166)
at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:1525)
at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:815)
at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:109)
at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:405)
at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3508)
at org.mozilla.javascript.InterpretedFunction.exec(InterpretedFunction.java:120)
at com.mirth.connect.server.util.javascript.JavaScriptTask.executeScript(JavaScriptTask.java:150)
at com.mirth.connect.connectors.js.JavaScriptDispatcher$JavaScriptDispatcherTask.doCall(JavaScriptDispatcher.java:149)
... 6 more
Issue could not be solved in Mirth connector Admin environment, to solve this issue, I used DB query instead.
go to Mirth DB, you can find related tables and it is more safe to query such DB.
The reason not to invoke,
answer from Mirth slack general channel,
"When using the Client class you're pretty much looping back to the server, since all the code is executed on the server anyways."
so always didn't com.mirth.connect.client.core.Client class in Mirth code.
Issue closed.
OutPut Image
im trying to make an addAction , the method is working just fine on symfony web app and i get the data inserted , but im getting this error on my project when running it . and im wondering what can i do to recognize the error
Connection Error , there was a networking error in the connection to http://localhost/KiddoEsprit/web/app_dev.php/ajoutermobile/aaaaaaaaaa/bbbbbbbbbb/
public void ajouterReclamation(Reclamation r){
ConnectionRequest con = new ConnectionRequest();
String Url = "http://localhost/KiddoEsprit/web/app_dev.php/ajoutermobile/" +r.getTitre()+ "/" + r.getContenu() ;
con.setUrl(Url);
con.addResponseListener((l) -> {
String str = new String(con.getResponseData());
System.out.println(str);
});
NetworkManager.getInstance().addToQueueAndWait(con);
}
the error is fixed when i started sending the object in a request
String Url = "http://localhost/KiddoEsprit/web/app_dev.php/ajoutermobile?titre=" + r.getTitre()+ "&contenu=" + r.getContenu() ;
and changed a few code lines on my symfony app
Here I am trying to get ASSET details in simple java
Here is the code
MXSession session = MXSession.getSession();
session.setHost("localhost:13400/MXServer");
session.setUserName(user);
session.setPassword(pwd);
session.connect();
The connection was successful.
Then I tried to get the asset details with the code
MboSetRemote assetMboSet = session.getMboSet("ASSET");
assetMboSet.setOrderBy("ASSETNUM");
MboRemote assetMbo;
for(int j=0; ((assetMbo = assetMboSet.getMbo(j)) != null); j++)
{
String assetNum = assetMbo.getString("ASSETNUM");
String location = assetMbo.getString("LOCATION");
String desc = assetMbo.getString("DESCRIPTION");
System.out.println(assetNum + " - " + location + " - " + desc);
}
it is giving me the error and could not proceed further in the line
MboSetRemote assetMboSet = session.getMboSet("ASSET");
saying
Exception in thread "main" psdi.util.MXSystemException: system#unknownerror
at psdi.util.RMISession.getMboSet(RMISession.java:330)
Please suggest me how to proceed
My friend I just tried your code scripth and it works fine, here is a snapshot of my environment which shows your work.
This problem may occur, If the admin mode is on OR you need to change take a look at sessions, to do that.
you can go to the users application.
Select action > manage sessions.
You can view users who are currently logged into the system.
You can log out a user from the system or log out and block a user from the system.
You can see the login history of users.
first time i'm using aws api in java to get the cloud watch statistics for my ec2-instance. i googled about this and i found some code snippet. here it is
AmazonCloudWatchClient cloudWatch = new AmazonCloudWatchClient(
new BasicAWSCredentials(AccessKey, SecretKey));
cloudWatch.setEndpoint("ec2-<my-static-ip>.compute-1.amazonaws.com");
long offsetInMilliseconds = 1000 * 60 * 60 * 24;
Dimension instanceDimension = new Dimension();
instanceDimension.setName("Instanceid");
instanceDimension.setValue(InstanceId);
GetMetricStatisticsRequest request = new GetMetricStatisticsRequest()
.withStartTime(
new Date(new Date().getTime()
- offsetInMilliseconds))
.withNamespace("AWS/EC2")
.withPeriod(60 * 60)
.withDimensions(
new Dimension().withName("InstanceId").withValue(
InstanceId))
.withMetricName("CPUUtilization")
.withStatistics("Average", "Maximum")
.withEndTime(new Date());
GetMetricStatisticsResult getMetricStatisticsResult = cloudWatch
.getMetricStatistics(request);
double avgCPUUtilization = 0;
List dataPoint = getMetricStatisticsResult.getDatapoints();
for (Object aDataPoint : dataPoint) {
Datapoint dp = (Datapoint) aDataPoint;
avgCPUUtilization = dp.getAverage();
System.out.println(InstanceId
+ " instance's average CPU utilization : "
+ dp.getAverage());
}
} catch (AmazonServiceException ase) {
System.out
.println("Caught an AmazonServiceException, which means the request was made "
+ "to Amazon EC2, but was rejected with an error response for some reason.");
System.out.println("Error Message: " + ase.getMessage());
System.out.println("HTTP Status Code: " + ase.getStatusCode());
System.out.println("AWS Error Code: " + ase.getErrorCode());
System.out.println("Error Type: " + ase.getErrorType());
System.out.println("Request ID: " + ase.getRequestId());
}
so, using this code i tried to get statistics, but first time it throws error saying
com.amazonaws.AmazonClientException: Unable to execute HTTP request:Connection to https://ec2-<my-static-ip>.compute-1.amazonaws.com refused
then i thought it was sending https requests. so i enabled ssl on my instance and tried, then i'm getting below exception.
com.amazonaws.AmazonClientException: Unable to execute HTTP request: peer not authenticated
i was using OpenJDK in my instance, so i thought that may causing the problem. then i removed openjdk and installed Oracle JDK 1.7. but still same problem.
My questions are,
1) how can i send only HTTP (instead of HTTPS) requests to get statistics?
2)how to get rid of this problem, so that i can get my results?
But please don't ask me to read any docs, because i messed up by searching in net, blogs,forums, docs... etc. then i end up here. so, please just provide me solution or tell me where i'm going wrong.
Can anybody please help me out this issue.
thank you in Advance.
Got Solution.
1) removed setting end point for AmazonCloudWatchClient.
2) problem with the AWS credentials (Access key ID, Secret key).So, i created another set of credentials and gave CloudWatchFullAccess policy for the user.
Now it is working like Charm... :-)
Thanks.
I've optimized my DB2-query with a WITH-clause. Now it is fast, but does not work under JDBC anymore. Does anyone has an idea? Thanks!
WITH tmp AS (SELECT ID_EINSENDUNG, BEURTEILUNG, VERSANDDAT_BVD, LASTUSER
FROM BVDT.TEINSENDUNG_BVD WHERE VERSANDDAT_BVD =
'2008-02-26' --HOST VARIABLE 1
)
SELECT ID_EINSENDUNG, VERSANDDAT_BVD FROM tmp WHERE ID_EINSENDUNG >
4100 --HOST VARIABLE 2
Error Message: ERRORCODE=-4461, SQLSTATE=42815 SQLState: 42815
ErrorCode: -4461
Java Code:
public DBCursor searchViewLandwirtOhrmarke() throws Exception {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("WITH tmp AS " +
"(SELECT ID_EINSENDUNG, BEURTEILUNG, VERSANDDAT_BVD, LASTUSER FROM BVDT.TEINSENDUNG_BVD WHERE VERSANDDAT_BVD = ?) " +
"SELECT ID_EINSENDUNG, VERSANDDAT_BVD FROM tmp WHERE ID_EINSENDUNG > ?");
prepareStatement(stringBuilder.toString());
ps.setDate(1, DateUtils.getSQLDate("26.02.2008"));
ps.setInt(2,new Integer(4100));
executeCursorSelect();
return this;
}
public EinsendungBvd nextViewLandwirtOhrmarke() throws Exception {
if (endFetch()) {
return null;
}
EinsendungBvd result = new EinsendungBvd(dbConn);
result.setId_einsendung(new Integer(rs.getInt(1)));
if (rs.wasNull()) {
result.setId_einsendung(null);
}
result.setVersanddat_bvd(rs.getDate(11));
return result;
}
Looks like a date format problem to me. Try changing your date in ps.setDate(1, DateUtils.getSQLDate("26.02.2008")); to ps.setDate(1, DateUtils.getSQLDate("2008-02-26"));. I don't know the DateUtil specs, so this is just a wild guess.. (see here for a list of SQLSTATE/ERRORCODES)
Looking at IBM DB2 LUW version 9.7 Error codes issued by the IBM Data Server Driver for JDBC and SQLJ for error code -4461:
-4461 text-from-getMessage 42815
Explanation: The specified value is invalid or out of range.
User response: Call SQLException.getMessage to retrieve specific information about the problem.
Things to try:
Log the value of SQLException.getMessage().
Verify the data types for VERSANDDAT_BVD and ID_EINSENDUNG.
Test the query with one parameter at a time; isolate which parameter is the violator.
Verify DateUtils.getSQLDate() is parsing your date string correctly; compare the result of Date.getTime() on the Date from DateUtils.getSQLDate()and the Date from SimpleDateFormat.parse().