cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Thingworx TO SQL

mtahir1
10-Marble

Thingworx TO SQL

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

ACCEPTED SOLUTION

Accepted Solutions
supandey
19-Tanzanite
(To:mtahir1)

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.

View solution in original post

5 REPLIES 5
supandey
19-Tanzanite
(To:mtahir1)

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>

 

@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?

supandey
19-Tanzanite
(To:mtahir1)

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.

@supandey Thanks a lot. thats exactly what I needed. Works like a charm!

supandey
19-Tanzanite
(To:mtahir1)

Glad it helped! :)

Announcements


Top Tags