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