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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Using a third party Jar file for Database connection

bmehringer
12-Amethyst

Using a third party Jar file for Database connection

I imported the relational database extension for DB2 connectivity, but the default JDBC driver class isn't what my organization uses to connect to DB2. We use another driver class called "com.ibm.as400.access.AS400JDBCDriver".  I tried setting this in the JDBC Driver Class Name field in the DB2 Thing configuration, but I wasn't able to query a database.  I have a Jar file that we typically have to deploy to use this DB2 connection driver and I assume I have to deploy this Jar file so that ThingWorx can see it and know it exists when I try to make a connection to a DB2 database.

How do I deploy Jar file with ThingWorx/Apache so that I can use this JDBC driver?

Here are my settings (some information has been generalized):

ACCEPTED SOLUTION

Accepted Solutions
posipova
20-Turquoise
(To:bmehringer)

Hi,

You may build your own jdbc package/extension:

  • Download the Extension Metadata file Here
  • Download the appropriate JDBC driver
  • Build the extension structure by creating the directory lib/common
  • Place the JAR file in this directory location:
    • lib/common/<JDBC driver jar file>
  • Modify the name attribute of the ExtensionPackage entity in the metadata.xml file as needed
  • Point the file attribute of the FileResource entity to the name of the JDBC JAR file
  • The metadata also contains a ThingTemplate
  • the name is set to MySqlServer, but can be modified as needed
  • Select the lib folder and metadata.xml file and send to a zip archive
    • Tip: The name of the zip archive should match the name given in the name attribute of the ExtensionPackage entity in the metadata.xml file
  • Import the newly created extension as usual
  • To the JDBC extension, simply create a new thing and assign it the new ThingTemplate that was imported with the JDBC extension

Configuration Field Explanation:

  • JDBC Driver Class Name
    • Depends on the driver being used
    • Refer to documentation
  • JDBC Connection String
    • ​Defines the information needed to establish a connection with the database
    • Connection string examples can be found in the ThingWorx Help Center
  • ConnectionValidationString
    • ​A simple query that will work regardless of table names to be executed to verify return values from the database
  • Alternatively, the ThingWorx Marketplace has a JDBC Connector Extension where you can upload and import third party JDBC drivers into the platform

Alternatively, you may download the jdbc connector creator from the marketplace here https://marketplace.thingworx.com/Items/jdbc-connector-extension

Then you may just view the mashup and use it to package your jdbc jar into an extension (which can be later imported into Thingworx).

Also, please refer to this topic Steps to connecting to your Relational Database

View solution in original post

4 REPLIES 4
posipova
20-Turquoise
(To:bmehringer)

Hi,

You may build your own jdbc package/extension:

  • Download the Extension Metadata file Here
  • Download the appropriate JDBC driver
  • Build the extension structure by creating the directory lib/common
  • Place the JAR file in this directory location:
    • lib/common/<JDBC driver jar file>
  • Modify the name attribute of the ExtensionPackage entity in the metadata.xml file as needed
  • Point the file attribute of the FileResource entity to the name of the JDBC JAR file
  • The metadata also contains a ThingTemplate
  • the name is set to MySqlServer, but can be modified as needed
  • Select the lib folder and metadata.xml file and send to a zip archive
    • Tip: The name of the zip archive should match the name given in the name attribute of the ExtensionPackage entity in the metadata.xml file
  • Import the newly created extension as usual
  • To the JDBC extension, simply create a new thing and assign it the new ThingTemplate that was imported with the JDBC extension

Configuration Field Explanation:

  • JDBC Driver Class Name
    • Depends on the driver being used
    • Refer to documentation
  • JDBC Connection String
    • ​Defines the information needed to establish a connection with the database
    • Connection string examples can be found in the ThingWorx Help Center
  • ConnectionValidationString
    • ​A simple query that will work regardless of table names to be executed to verify return values from the database
  • Alternatively, the ThingWorx Marketplace has a JDBC Connector Extension where you can upload and import third party JDBC drivers into the platform

Alternatively, you may download the jdbc connector creator from the marketplace here https://marketplace.thingworx.com/Items/jdbc-connector-extension

Then you may just view the mashup and use it to package your jdbc jar into an extension (which can be later imported into Thingworx).

Also, please refer to this topic Steps to connecting to your Relational Database

Brent,

Any update on this? Was Polina Osipova's post helpful? If so, could you click on the "correct answer" or "mark as helpful" button and let us know?

Hi Jeremy,

Polina's answer was exactly correct.

Thanks Polina for the prompt reply.

Thanks Brent!

Announcements


Top Tags