From the course: Scala Essential Training for Data Science

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Connecting to PostgreSQL

Connecting to PostgreSQL - Scala Tutorial

From the course: Scala Essential Training for Data Science

Start my 1-month free trial

Connecting to PostgreSQL

- [Instructor] Now we'll start Scala and we'll use JDBC to connect to our database. So, we'll specify scala to start the REPL but this time we're going to to something a little different. We're going to include a classpath option and I'm going to specify the directory where I downloaded my JDBC driver and for me I downloaded it to this directory. Now, your classpath may be different depending on where you downloaded the JDBC driver and be sure to include the name of the jar file in the classpath. First thing I want to do is import a couple of classes that will allow us to work with SQL from within Scala. So, we'll import java.sql. DriverManager and I'm just hitting tab here to show you the different things that we have available to us. DriverManager and I also want to import java.sql.Connection. So, now we have our two packages installed, so I'm just going to clear the screen and now I want to define a couple of strings that we'll use when we connect to the database. The first I'll…

Contents