Focus HMI Panel Database

Focus HMI panel uses SQLITE database. Automatically records and reports data. You can access database data with scripts. Sample code is shared below. After copying and pasting this code, correct the quotation marks.

import java.sql.SQLException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import java.sql.ResultSet;
public class sql{
public sql(Class Accessing){
String url = “jdbc:sqlite:” + “c:\\ABC\\FocusHmi\\LastValueDB.sqlite”;
try (Connection conn = DriverManager.getConnection(url)) {
if (conn != null) {
javax.swing.JOptionPane.showMessageDialog(null , “Connected”);
String sql = “SELECT Count(*) FROM MyTable”;
Statement stmt = conn.createStatement();
ResultSet rs=stmt.executeQuery(sql);
javax.swing.JOptionPane.showMessageDialog(null , rs.getInt(1));
javax.swing.JOptionPane.showMessageDialog(null , “Not Connected”);
} catch (SQLException exp) {
javax.swing.JOptionPane.showMessageDialog(null , exp.getMessage());

Leave a Reply