Thursday, October 21, 2021

Connect to a SQLite Database in Java

Sometimes you need to connect to a database. Here is some code that will allow you to connect to an SQLite database using Java.


public static Connection connect() {
Connection conn = null;
try {
conn = DriverManager.getConnection("jdbc:sqlite:sample.db");
} catch (SQLException sqle) {
sqle.printStackTrace();
Logger.getLogger(SQLite.class.getName()).log(Level.SEVERE, null, sqle);
}
return conn;
}

No comments:

Post a Comment

Ever feel like no one is listening?

 Ever have that feeling that no one is listening to you? Yeah, that feeling. It can be a strong feeling to have, a hurtful feeling also. The...