java.sql.DriverManager.getConnection method

A Java application that uses the JDBC API establishes a connection to a database by obtaining a Connection object. The standard way to obtain a Connection object is to call the method DriverManager.getConnection, which takes a String that contains a database connection URL.

A JDBC database connection URL (uniform resource locator) provides a way of identifying a database.

DriverManager.getConnection can take one argument besides a database connection URL, a Properties object. You can use the Properties object to set database connection URL attributes. If you specify any attributes both on the connection URL and in a Properties object, the attributes on the connection URL override the attributes in the Properties object.

You can also supply strings representing user names and passwords. When they are supplied, Derby checks whether they are valid for the current system if user authentication is enabled. User names are passed to Derby as authorization identifiers, which are used to determine whether the user is authorized for access to the database and for determining the default schema. When the connection is established, if no user is supplied, Derby sets the default user to APP, which Derby uses to name the default schema. If a user is supplied, the default schema is the same as the user name.

Related reference
java.sql.Driver interface
java.sql.Connection interface
java.sql.DatabaseMetaData interface
java.sql.Statement interface
java.sql.CallableStatement interface
java.sql.PreparedStatement interface
java.sql.ResultSet interface
java.sql.ResultSetMetaData interface
java.sql.SQLException class
java.sql.SQLWarning class
java.sql.SQLXML interface
java.sql.Savepoint interface
Mapping of java.sql.Types to SQL types
Features supported on JDBC 4.1 and above
JDBC 4.2-only features
JDBC escape syntax