Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Rashid Coder
Added: Feb 3, 2018 2:51 PM
Views: 21
SQLite Connection
  1. package helpers;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.SQLException;
  6. import java.util.logging.Level;
  7. import java.util.logging.Logger;
  8.  
  9. /**
  10.  *
  11.  * @author Jamil Hussain
  12.  */
  13. public class DBConnection {
  14.  
  15.     public static Connection connect() {
  16.         Connection con = null;
  17.         try {
  18.             String url = "jdbc:sqlite::resource:DATA.db";
  19.  
  20.             Class.forName("org.sqlite.JDBC");
  21.            
  22.             con = DriverManager.getConnection(url);
  23.             System.out.println("Sucess");
  24.  
  25.         } catch (ClassNotFoundException | SQLException ex) {
  26.             Logger.getLogger(DBConnection.class.getName()).log(Level.SEVERE, null, ex);
  27.         }
  28.  
  29.         return con;
  30.     }
  31. }
  32.