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

No Sleep

 This is the second day I've woken up early. Like way earlier than normal. Like four am early. I don't know what to do about it. I n...