- GetSnap uses the PI JDBC Driver to connect to a PI SQL Data Access Server (OLEDB), which then uses the PI OLEDB Provider to connect to the specified PI Data Archive to retrieve the snapshot value of the specified tag.
- GetEASnap uses the PI JDBC Driver to connect to a PI SQL DAS (OLEDB), which then uses the PI OLEDB Enterprise to connect to the specified AF Server to retrieve the snapshot value of all attributes on the specified element.
The purpose of this is to use the example Java class provided to understand the basics of building a JDBC connection, including connection string building. Making a change to the utility requires a very basic level of Java and PI SQL knowledge, making it a good teaching example for beginners. Going through this example will also showcase the usefulness of this utility for a Java developer trying to get started with the PI JDBC Driver.
The specific changes we will make to the 32-bit version of GetSnap in this tutorial will be:
- Retrieve interpolated values for the last 2 hours instead of snapshot values
- Set the default timestep for interpolated queries to 30m so the query itself does not need to specify this
Notes about this environment:
- The PI SQL DAS (OLEDB) service is installed locally to the PI JDBC Driver, so it can be referred to as "localhost"
- The PI Data Archive name is PISRV01
- The user account being passed to the PI SQL DAS (OLEDB) service is student01
- Note: this is a domain account that the PI OLEDB Provider then passes to the PI Data Archive. This account has a mapping, and it is not a PI user for explicit logon
- This is a development/test environment, so the PI SQL DAS certificate is not validated. If this were a production environment, it would be very important to validate this certificate.
Before getting started, confirm that the existing GetSnap utility can connect to your PI SQL DAS (OLEDB) and PI Data Archive to retrieve a value for sinusoid. This will confirm that the Java Runtime Environment (JRE) is installed, the PI JDBC Driver can communicate with the PI SQL DAS (OLEDB), the PI OLEDB Provider can communicate with the PI Data Archive via PI SDK, and the PI Snapshot Subsystem can return the value for sinusoid.
Steps to customize GetSnap:
- Using the PI OLEDB Provider user guide:
- Using PI SQL Commander on the machine running the PI SQL DAS (OLEDB) service:
- Navigate to %pihome%\JDBC\Samples\GetSnap\src and make a copy of the getSnap.java and give a new name, such as GetSnapCustom.java
- Open this new file in notepad or a Java IDE (such as Eclipse or NetBeans) and make the necessary changes:
- Compile GetSnapCustom.java into GetSnapCustom.class placing it in the ..\bin directory (we will use javac but you're welcome to use your JDE)
- Run the new version of the utility, passing it the same parameters from before, and observe the new output