This blog’s tagline is adapted from the Emacs Org-Mode motto. It seemed appropriate, as I seem to have spent most of my life writing novels and short stories (of which you can find out more at tonyballantyne.com) or teaching computer coding.

I’ve amassed a lot of material over the years, and I wanted to share it with people who may not have had the same access to education as people living in my country are lucky enough to have. If you want to change the world, become a teacher.

As the the teaching of coding seems to be coming back into fashion, I’ve also included my thoughts on the pedagogy of this subject.

All comments are gratefully received.

No Charge, No Adverts. If you’d like to show your appreciation, please follow me on Twitter @TonyBallantyne

All Materials Copyright (c) Tony Ballantyne 2022

JDBC 1: Set up

Create a Database to query

First, set up a MySQL database. For the purposes of this demonstration I set up a simple database called bluecoat with one table: student. The table has four columns of type varchar: Forename, Surname, Gender and Form.

Update: Follow this link to watch a YouTube demonstration of this lesson

Add mysql-connector JAR

You will need to download the mysql-connector JAR and add it to your classpath. Consult your IDE’s documentation on how to do this.

You can find the JAR here: https://dev.mysql.com/downloads/connector/j/

If you’re using Netbeans, right click on the Libraries folder and choose Add JAR/Folder

The JAR is installed by default in the ext folder on windows:

Quick Start

The following code will connect to a database called bluecoat running on a mysql server on port 3306 of localhost. I used XAMPP to write this tutorial: by default the username of the database was root, the password was left blank.

try {
//Load mysql jdbc Driver      
// Connect to Database      
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/bluecoat", "root", "");
} catch (Exception ex) {

Run the code. If it doesn’t throw an exception, you’re successfully connected!