===================================================== Sample to Illustrate Using LiveView with a JDBC Table ===================================================== ____________ Introduction This sample demonstrates the use of a JDBC database in LiveView. The sample represents an equipment-monitoring system that records events from 15 different devices and allows you to monitor or troubleshoot those devices by noting irregularities in the event stream. The Apache Derby database system is used in this sample to illustrate JDBC connection principles. Note that Derby is not a supported JDBC configuration for use in production environments. To run the LiveView JDBC Sample, follow these steps: 1. Start the Apache Derby database instance using the "Step 1 - Start Database" launch file. 2. (One-time) Load the database using the "Step 2 - once only - Create and Load Tables" launch file. In the Project Explorer view, all launch files are located in the sample's src/main/resources/launchers folder. __________________ Start the Database a. Select the launchers/Step 1 - Start Database.launch file. b. Right-click and choose Run As. c. Choose Step 1 - Start Database. This launches a Derby database instance, which is now ready for connections. ___________________________ Load Sample Data into Derby This step must be done only once per import of this project into your Studio workspace. Repeating it will just re-import the same data. a. Select the launchers/Step 2 - once only - Create and Load Tables.launch file. b. Right-click and choose Run As. c. Choose Step 2 - once only - Create and Load Tables. This creates the tables in the Apache Derby database and imports data from the CSV files. The CONNECT statement should not produce any errors. If this is the first time you are running this launcher, then there will be errors on the DROP TABLE statements, because they are just there to clean up if you run this a second time. _________________________ Start the LiveView Server Select the sample project in the Package Explorer and right click, selecting Run As -> LiveView Fragment. Wait for the server to start - look for: "All tables have been loaded. LiveView is ready to accept client connections." ______________________ View the Data in the Tables You can view the data in the tables via LiveView client. You can use the lv-client command line, or use LVWeb by connecting to the server with a browser at http://localhost:10080. You will see the following: - DeviceTrack table: This is a standard LiveView Data Table showing the simulated live data. - Devices table: This is a JDBC table of the Devices that are being managed by this application. - Service Data table: This is a JDBC table of the service data for the selected device. You can select a particular device by double-clicking in either of the other two tables. __________________ Stop the Database If you go to the Debug view and right click on the "Step 1 - Start Database" process, then select terminate. This sample also includes two configuration files of type HOCON, located in src/main/configurations: engine.conf - a LiveView configuration file to set up JVM arguments for this sample. sample.conf - a configuration file to set up the JDBC data source for this sample. Alternatively, to run this sample in Studio, you can: - In the LiveView Project Viewer, click the green Run button in the upper right. - Right-click any of the lvconf table configuration files in the Project Explorer view and select Run As > Run Configurations > Run (in the invoked Run Configurations dialog). - Right-click the project folder itself, and select Run As > LiveView Fragment To run this sample from the command line outside of Studio, you must: - Package this sample's LiveView fragment project into a fragment archive. - Create a separate StreamBase Application project, and set the pom.xml for that project to depend on the fragment archive created in the previous step. - Create a separate StreamBase Application archive file. - Install that archive into a StreamBase Runtime node. - Start the node. These steps are described in more detail in the "Deploy with epadmin" page of the Concepts Overview in the StreamBase documentation.