A Connection object represents a connection with a database.

Within the scope of one Connection, you access only a single Derby database. (Database-side JDBC routines can allow you to access more than one database in some circumstances.) A single application might allow one or more Connections to Derby, either to a single database or to many different databases, provided that all the databases are within the same system.

With DriverManager, you use the connection URL as an argument to get the getConnection method to specify which database to connect to and other details.

The following example shows an application establishing three separate connections to two different databases in the current system.

Connection conn = DriverManager.getConnection(
System.out.println("Connected to database sample");
Connection conn2 = DriverManager.getConnection(
System.out.println("Created AND connected to newDB");
Connection conn3 = DriverManager.getConnection(
System.out.println("Got second connection to newDB");

A Connection object has no association with any specific thread; during its lifetime, any number of threads might have access to it, as controlled by the application.

Related concepts
Derby system
Derby JDBC database connection URL