Never confuse education with intelligence, you can have a PhD and still be an idiot.
- Richard Feynman -

JavaDB:Introduction to JDBC

From Juneday education
Revision as of 16:15, 8 March 2019 by Rikard (Talk | contribs) (Requirements: new section)

Jump to: navigation, search

Full frontal - Code up-front

We don't expect you to understand the following code, but believe that it's always good to be exposed to code early on.

try (Statement stm = con.createStatement() ) { // try-with-resources
  String query = "SELECT Name, HTTPS FROM municipalities LIMIT 5";
  ResultSet rs = null;
  rs = stm. executeQuery(query);

  while ( ) {
    System.out.println(rs. getString("Name") + " " +
                      (rs. getBoolean("HTTPS") ? "HTTPS support" : "HTTP only") );
} catch (SQLException sqle) {


This chapter introduces you to the basics of using the JDBC API for using databases with Java.

We will introduce some of the interfaces in java.sql like:

  • Connection
  • Statement
  • ResultSet

And some of the classes:

  • DriverManager
  • SQLException

We encourage you to read the external resources (further reading links) below, after watching the video.


In order to fully understand this chapter, we assume you have basic knowledge of SQL and SQLite. If you feel that you need to freshen up on SQL, we recommend our book Introduction to Databases.

A complete example

Lecture slides and videos

English videos

No English videos yet, but we are planning to make some soon!

Swedish videos


External links

Chapter links

After this chapter you should move on to the Exercise - Introduction to JDBC chapter.

« PreviousBook TOCNext »