Ted pottel
Ted pottel

Reputation: 6983

Trying to connect to a SQLite database, keep getting no Suitable Driver Found

When I call The staement

c = DriverManager.getConnection("jdbc:sqlite:sample.db");   

I get a exception saying

no Suitable Driver Found for jdbc:sqlite:sample.db

The project is running in eclipse on a windows platform.

This is what I did:

  1. WENT TO properties-> java build path -> Add external jar
  2. added the file sqllite-3-16-1.jar

The code

  try {
      // exception goes off here
      c = DriverManager.getConnection("jdbc:sqlite:sample.db");     
  } catch(Exception e){
            ted=ted+1;      
  } // 

Upvotes: 0

Views: 2117

Answers (1)

Darshan Mehta
Darshan Mehta

Reputation: 30809

You need to load the driver class before trying to acquire the connection. Can you try the following:

Class.forName("org.sqlite.JDBC");

This will throw NoClassDefFoundError if the driver jar is not on the classpath.

Upvotes: 3

Related Questions