Forem

Carter
Carter

Posted on

1 1

Java JDBC + IntelliJ + SQLite - A Beginner's Walkthrough

IntelliJ Community + JDBC + SQLITE

(or any other database)

  • no build tool required (Maven or Gradle)
  • we'll be downloading the sqlite command-line shell (https://www.sqlite.org/cli.html)
    • this will make it easy to create a database file and use it as our connection in jdbc.
  • sqlite drivers from (org.xerial.sqlite)

Step 1: Project Setup

1.1 create a new project

File > New > Project..

Image description

click on New Project
pick a name for your project (we will be calling it jdbc-test)
click Create

1.2 adding the sqlite driver

Image description

once your new project is created go to

File > Project Structure > Libraries

click the + sign and then Maven
(you could also download the jar yourself
sqlite driver jar,
Maven just does it for you)

Image description

  • search for org.xerial.sqlite-driver and use the latest version (3.42.0.0 as of this commit)
  • optional: you can choose to store your library in a lib folder for organizational purposes.
  • click okay to add the dependency.

Step 2: Getting a Database File with the SQLite

2.1 downloading the tool

Image description

visit the sqlite downloads page
install the precompiled binaries for your target OS

  • make sure your download has the following description:

A bundle of command-line tools for managing SQLite database files,
including the command-line shell program, the sqldiff.exe program,
and the sqlite3_analyzer.exe program.

2.1 identifying your tools

Image description

  • unzip the downloaded folder and view the contents inside.
  • you should see sqldiff, sqlite3, and sqlite3_analyzer.
  • you are only interested in sqlite3 for now.
  • start sqlite3

2.3 using sqlite3 cli

Image description

  • to create a new database file simply type

.save [name-of-database-file]

  • this will create a new file in the same folder as the sqlite3 application.

2.4 handling the database resource file

  • move the file into your IntelliJ Community Edition project.
  • you can store in the root directory or in some resource folder

Image description

Step 3: Using JDBC and SQLite

you are now ready to start using Sqlite and JDBC!

look through the source code for a quick example using our newly created database file.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more →

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Explore a sea of insights with this enlightening post, highly esteemed within the nurturing DEV Community. Coders of all stripes are invited to participate and contribute to our shared knowledge.

Expressing gratitude with a simple "thank you" can make a big impact. Leave your thanks in the comments!

On DEV, exchanging ideas smooths our way and strengthens our community bonds. Found this useful? A quick note of thanks to the author can mean a lot.

Okay