-2

I am trying to connect sqlite db browser with java using nano editor i am very new here. i have followed some youtube videos but i am stacking at mid can anyone please help here is my code.

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

public class SqliteDB{

Connection c = null;
Statement stmt = null;

SqliteDB(){
try{
 Class.forName("org.sqlite.JDBC");

 c = DriverManager.getConnection("jdbc:sqlite:signup.db");
  System.out.println("Connected to DB");

  }
  catch(Exception e){
    System.out.println("Error: "+ e.getMessage());

  }
 }
 }


  Error: org.sqlite.JDBC
 thank you guys for helping. 

1 Answers1

0

I think that you have not imported library org.sqlite.JDBC in your project, Class.forName() return class that exists, when you get error like this it says that this class is not exists.

First of all download library from: https://bitbucket.org/xerial/sqlite-jdbc/downloads/

Then import in your project and that's how you should write the code:

public static void main(String[] args) throws SQLException {
        org.sqlite.JDBC j =  new org.sqlite.JDBC();
        Connection c = DriverManager.getConnection("jdbc:sqlite:signup.db");
        //do stuff here
    }