Skip to main content
1-Visitor
July 27, 2018
Solved

Thingworx TO SQL

  • July 27, 2018
  • 1 reply
  • 2864 views

Hello,

I can connect to a database using the mssql jdbc settings. I want to connect more than 1 database on the same server and port. Is it possible with some syntax that I dont know like commas between database name and connect to 2 different database on the same server from one single thing?

e.g: jdbc:sqlserver://143.3.3.154;DatabaseName=table1,table2,table3

Best answer by supandey

The join i've referred involves multiple databases, sorry I missed to mention if you review the syntax thingworx & demoDB are two different databases I have. 

 

So basically with a thing connecting to 1 database I can still query different database, which I have not configured in my JDBC connection URL, e.g.

 

I have this as my JDBC : jdbc:sqlserver://localhost:1433;databaseName=thingworx; configured for myDatabaseThing

 

But I can query another database from this same thing using following select :

 

select * from demoDB.dbo.table1

 

Will this not help your use case?

 

I'm not aware if you can actually have multiple databases listed as comma separated in JDBC.

1 reply

5-Regular Member
July 27, 2018

Hi @mtahir1 does your use case performing similar selects queries on multiple databases? I'm not aware of putting databases like that with comma separated, but you should be able to query and database given that your user has sufficient access rights for e.g. 

 

select * from thingworx.dbo.data_table and if you are looking to join that query you can build join using select * from demoDB.dbo.demoTable

 

the syntax above is <databaseName>.dbo.<tableName>

 

mtahir11-VisitorAuthor
1-Visitor
July 27, 2018

@supandey Im sorry I think I wasnt clear with my syntax. I know how to join different tables from the same database with joins. But my question is 1 thing is connected to 1 database. Can I connect 1 thing to more databases?

supandey5-Regular MemberAnswer
5-Regular Member
July 27, 2018

The join i've referred involves multiple databases, sorry I missed to mention if you review the syntax thingworx & demoDB are two different databases I have. 

 

So basically with a thing connecting to 1 database I can still query different database, which I have not configured in my JDBC connection URL, e.g.

 

I have this as my JDBC : jdbc:sqlserver://localhost:1433;databaseName=thingworx; configured for myDatabaseThing

 

But I can query another database from this same thing using following select :

 

select * from demoDB.dbo.table1

 

Will this not help your use case?

 

I'm not aware if you can actually have multiple databases listed as comma separated in JDBC.