Any comments i could add to this? package attendance; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; import java.sql.Statement; public class SqliteDB { Connection conn = null; Statement stmt = null; public SqliteDB() throws ClassNotFoundException { //try to connect with db try { Class.forName("org.sqlite.JDBC"); // db parameters String url = "jdbc:sqlite:C:/sqlite/db/attendance.db"; // create a connection to the database conn = DriverManager.getConnection(url); System.out.println("Connection to SQLite has been established."); } catch (SQLException e) { System.out.println(e.getMessage()); } } public void executeQuery(String query) { try { this.stmt = conn.createStatement(); stmt.execute(query); }catch (Exception e) { System.out.println(e); } } public void closeConnection() { try { this.conn.close(); }catch( Exception e) { System.out.println(e); } } }

Systems Architecture
7th Edition
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Stephen D. Burd
Chapter3: Data Representation
Section: Chapter Questions
Problem 3RP
icon
Related questions
Question

Any comments i could add to this?

package attendance;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;


public class SqliteDB {

Connection conn = null;
Statement stmt = null;


public SqliteDB() throws ClassNotFoundException {
//try to connect with db
try {
Class.forName("org.sqlite.JDBC");

// db parameters
String url = "jdbc:sqlite:C:/sqlite/db/attendance.db";
// create a connection to the database
conn = DriverManager.getConnection(url);

System.out.println("Connection to SQLite has been established.");

} catch (SQLException e) {
System.out.println(e.getMessage());
}
}


public void executeQuery(String query) {
try {
this.stmt = conn.createStatement();
stmt.execute(query);
}catch (Exception e) {
System.out.println(e);
}
}

public void closeConnection() {
try {
this.conn.close();
}catch( Exception e) {
System.out.println(e);
}
}


}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Procedures in SQL
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Systems Architecture
Systems Architecture
Computer Science
ISBN:
9781305080195
Author:
Stephen D. Burd
Publisher:
Cengage Learning
Oracle 12c: SQL
Oracle 12c: SQL
Computer Science
ISBN:
9781305251038
Author:
Joan Casteel
Publisher:
Cengage Learning
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
CMPTR
CMPTR
Computer Science
ISBN:
9781337681872
Author:
PINARD
Publisher:
Cengage
Np Ms Office 365/Excel 2016 I Ntermed
Np Ms Office 365/Excel 2016 I Ntermed
Computer Science
ISBN:
9781337508841
Author:
Carey
Publisher:
Cengage
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning