Skip to main content

Connection Setup

Learn Connection Setup (JDBC Basics, JDBC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Before you can run any SQL from Java, you need a live Connection to the database. Throughout this topic we assume a MySQL database company with a table: employees(id INT, name VARCHAR(50), salary DOUBLE, department VARCHAR(50)) Setting up a connection has three ingredients: • The JDBC driver (a JAR on your classpath, e.g. mysql-connector-j ). • A connection URL describing where the database lives. • Credentials ( username / password ).

More lessons in JDBC Basics