Data Subscription in TDengine through Java RESTful API - rest

I'm using a time series database called TDengine.
I want to try the data subscription according the document:
TSDBSubscribe sub = ((TSDBConnection)conn).subscribe("topic", "select * from meters", false);
Then I got an error:
java.lang.ClassCastException: com.taosdata.jdbc.rs.RestfulConnection cannot be cast to com.taosdata.jdbc.TSDBConnection
What may be the problem?

Related

Is there a way to stop this error "select * from "client_api_key" where "api_key" = $1 limit $2 - Connection terminated unexpectedly"

Im using adonis.js , I have the following query... When I make a request to my API this is the first database query. I get the above error only once every hour or so. Im using render.com to host my API and postgres database. I believe adonis.js uses knex and this maybe the problem but I am not sure.
const api_key_check = await database
.table('client_api_key')
.where('api_key', api_key_encoded)
.first()
It looks like knex have an open issue since node's 12 release.
Follow this thread and see if some proposed solution works for you:
https://github.com/knex/knex/issues/3523#issuecomment-722574083

Mirth Database Reader failed to process row retrieved from the database in channel (index out of range)?

I have a Mirth (v3.10) Database Reader channel source that grabs some test records (from an SQL Server source) using the query...
select *
from [mydb].[dbo].[lab_test_MIRTHTEST_001]
where orc_2_1_placer_order_number
in (
'testid_001', 'testid_002', 'testid_003'
)
Even though the channel appears to function properly and messages are getting written to the channel destination, I am seeing SQL errors in the server logs in the dashboard when deploying the channel:
[2020-12-16 08:16:28,266] ERROR (com.mirth.connect.connectors.jdbc.DatabaseReceiver:268): Failed to process row retrieved from the database in channel "MSSQL2SFTP_TEST"
com.mirth.connect.connectors.jdbc.DatabaseReceiverException: com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range.
at com.mirth.connect.connectors.jdbc.DatabaseReceiverQuery.runPostProcess(DatabaseReceiverQuery.java:233)
at com.mirth.connect.connectors.jdbc.DatabaseReceiver.processRecord(DatabaseReceiver.java:260)
...
I can run this query fine in the SQL Server Mgmt Studio itself (and the messages seem to be transmitting fine), so not sure why this error is popping up but am concerned there is something I'm missing here.
Anyone with more experience know what is going on here? How to fix?
The issue looks to be in the post-process SQL section of the Database Reader, so it makes sense that the messages appear to be working.
Did you intend to enable the post-process section at the bottom of your source tab?
Kindly share the code that you are using to process data in the result set. In the meantime, you can consider the code below as a staring point. You can place this in Javascript transformer step in the source connector of your channel.
//Declaring variables to hold column values returned from the result set
var variable1;
var variable2;
//defining the sql read command
var Query = "select * from [mydb].[dbo].[lab_test_MIRTHTEST_001]";
Query += " where orc_2_1_placer_order_number in";
Query += " ('testid_001', 'testid_002', 'testid_003')";
var result = dbconn.executeCachedQuery(Query);
//where dbconn is your database connection string
//looping through the results
while(result.next())
{
variable1=result.getString("variable1");
variable2 = result.getString("variable2");
}
//optionally place the returned values in a channel map for use later
$c('variable1',variable1);
$c('variable2',variable2);

Azure Data Factory V2: MDX Query on SAP BW exception Microsoft.DataTransfer.Common.Shared.HybridDeliveryException

I am trying to fetch data from SAP BW system into Azure Data Lake using MDX Query in SAP BW connector. But I am getting exception message in Azure is following :
{
"errorCode": "2200",
"message": "Failure happened on 'Source' side. ErrorCode=UserErrorInvalidDataValue,'Type=Microsoft.DataTransfer.Common.Shared.HybridDeliveryException,Message=Column '[Measures].[SomeMeasure]' contains an invalid value '4.000-2'. Cannot convert '4.000-2' to type 'Decimal'.,Source=Microsoft.DataTransfer.Common,''Type=System.InvalidCastException,Message=Specified cast is not valid.,Source=Microsoft.DataTransfer.Common,'",
"failureType": "UserError",
"target": "Copy1"
}
From the error, I can understand there are some values in Measures which is not actually numeric value. Changing or correcting value in the SAP system is not in my scope.
Is there any option in the Data Factory V2 for SAP BW connection so that I can define the data type of the Measure for input and/or output. or there is any fine-tuning in the MDX query so that I can fetch the data without any error?
This is my MDX Query :
SELECT
{[Measures].[SomeMeasure]} ON COLUMNS,
NON EMPTY
{ [0COMP_CODE].[LEVEL01].MEMBERS *
[0COSTELMNT].[LEVEL01].MEMBERS }
ON ROWS
FROM SomeQube
WHERE {[0FISCPER].[K42015008]}
If you could skip that incorrect rows, you could set enableSkipIncompatibleRow in as true. Please reference this doc.
Your filter is incorrect. SAP 0FISCPER dimension is in YYYYMMM format. You need to enter WHERE {[0FISCPER].[2015008]}. I am almost certain the "K4" you entered there is your fiscal year variant, which you should not put there. Objects like this K4 are called compounding infoobject (which your fiscal year/period belongs to if you envision it as hierarchical parent/child structure). But in this specific case, you don't need to specify fiscal year variant. Just remove K4.
I highly advise against skipping "incorrect rows". My guidance to you is that you should always fail the job whenever exception happens and investigate the data quality issue. Do not ever put enterprise data integrity at risk. SAP data has to be 100% accurate, not 99.9999%.

spring data rest update produce cross join sql error

I want to use spring data rest to update rows of certain user , but at run time this query has strange "cross join" added to the query .
spring data rest method
#Modifying
#Transactional
#Query("Update Notification n SET n.noticed = true Where n.notificationPost.owner.userId = 1 ")
public void postNoticed();
run time created query
Hibernate: update notification cross join set noticed=true where owner_id=?
My only concern is why "cross join" added as it gives sql error
org.postgresql.util.PSQLException: ERROR: syntax error at or near "cross"
I call this method directly by rest invoke , and also from mvc controller, both ways produce the same error
Thanks in advance.
Found solution as stated in http://forum.spring.io/forum/spring-projects/data/114271-spring-data-jpa-modifying-query-failure
"No joins, either implicit or explicit, can be specified in a bulk HQL query. Sub-queries can be used in the where-clause, where the subqueries themselves may contain joins. "(Hibernate doc reference: http://docs.jboss.org/hibernate/core.../#batch-direct)."
So I edited my code to use sub query
#Modifying
#Transactional
#Query("Update Notification n SET n.noticed = true Where n.notificationPost.postId in (SELECT n2.notificationPost.postId FROM Notification n2 where n2.notificationPost.owner.userId =:#{#security.principal.user.userId}) ")
public int postNoticed();

Not able to execute sql query with traverse in Orientdb restapi

I am new to OrientDB. I am trying to run the query "traverse * from #11:4 while $depth<=3" on the REST client (mentioned here). The query gives a valid graph with correct nodes when run on the local orientDB client. But gives the following error while trying to run the REST client.
Query,
http://localhost:2480/query/sample/sql/traverse * from #11:4 while $depth<=3
Response
com.orientechnologies.orient.core.exception.OQueryParsingException: Error on parsing query at position #8: Missed FROM
Query: traverse * from
-------------^
Can any of you highlight as to what is going wrong?
Did you escape # in your http call?
Seems like this problem
traverse * from
This is the query that arrive to OrientDb so i'm guessing it is a # problem
You can also use POST command instead of GET query so you can put the query in the body
see here
http://www.orientechnologies.com/docs/last/orientdb.wiki/OrientDB-REST.html#post---command