Java Connect to SQLite Database Example

preview_player
Показать описание
Learn how to connect to SQLite database in Java applications via JDBC. What you will learn in details:
- What is SQLite database?
- Download JDBC driver for SQLite
- Code a Java program that connects, inserts and retrieves data from a SQLite database
- How to use Maven dependency for SQLite JDBC driver
- How to use sqlite command line tool program to manage SQLite database files
Рекомендации по теме
Комментарии
Автор

sir, I have been stuck in my sqlite error for weeks now and have been contemplating on what course to shift to because i am not connecting to sqlite at all, debugging sucks, you are literally my life saver may you continue saving desperate novice programmers like me

preciousjumuad
Автор

Absolutely fantastic video. 10/10. Thank you so much.

heitornolla
Автор

Well, thank you man! I did mine with more OOP involved, and I am hoping to make it so that I can choose my specific query in the db:

package queryDatabaseTestUsingJDBC1;

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

public class databaseManager {
static String databaseUrl; //Store the directory/address to the database (.db) file.
static Connection databaseConnection; //Instance of database; JDBC lib.
static Statement sqlStatement; //Manages sql statements; JDBC lib.
static ResultSet result; //Manages the result; JDBC lib.
static String STUDENT_ID;
static String STUDENT_NAME;
static String AGE_IN_YEARS;

//Constructor of class "databaseManager". Take in database address/directory when instane of class is created.
public databaseManager(String Url) {
databaseUrl = Url;
}

//Return the address, Url or directory of the database.
public String getDatabaseUrl() {
return databaseUrl;
}

//Connect to a database using url provided by constructor; Conntains JDBC lib.
public void connectToDatabase() {
try {
databaseConnection =
} catch (SQLException e) {
to sqlite database failed...\n");
e.printStackTrace();
}
}

//Query the sql database, takes sql statement.
public void queryDatabase(String passedSqlStatement) {
try {
sqlStatement = //Create sql statement.
result = //Execute the query on the database.

//Print result.
while (result.next()) { //Get all results.
STUDENT_ID =
STUDENT_NAME =
AGE_IN_YEARS =

+ " | " + STUDENT_NAME + " | " + AGE_IN_YEARS + "\n");
}

} catch (SQLException ea) {
System.out.print("Error quering database...\n");
ea.printStackTrace();
}

}


}

X-VIPRIN
Автор

after going to alot videos ...finally i got it .Thankeww Man ...Love from india

utkarshmishra
Автор

Hey, I got an error. No suitable driver found for On the String i put the correct location but I still got this error. I don't know what should be wrong. String jdbUrl =

cesarbranco
Автор

despite adding the jar for jdbc to the class path like shown in the video, I am still getting the error "No suitable driver found" do you have any idea how to fix this? Thank you

mohammadzaidi
Автор

can you show us how to make a login gui with java/javafx that displays a different screen depending on the type of user that's logged in?

dkg
Автор

im using intellij and i added the jar file to the libraries section of my project and made sure that it gets exported in the dependencies tab i also made sure im specifiying the correct path for it but it still dosent work im getting this error:

Exception in thread "main" java.sql.SQLException: No suitable driver found for

redness
Автор

May I ask why did you specifically used Java 1.8

goldenscavengerplayz
Автор

hello! i am using intellij and i added the jar file inside project structure and the jar file is in the same file location as my project, but i am still getting no suitable driver found for jdbc:sqlite:/C:...

cxl
Автор

Do you know how i can use the local path to the database?

mysticknight
Автор

How do I add the jar file in sublime text

danishkh
Автор

11:30 Did this man just declare a variable in a while loop?

X-VIPRIN
Автор

I use vscode, and I've added the jar file to my referenced libraries but it still doesn't work.

c: && cd && cmd /C ""C:\Program App "
error connecting to db
java.sql.SQLException: No suitable driver found for jdbc:sqlite:/usersDB.db
at
at
at App.main(App.java:10)

michaelumeokoli