Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Before you can issue SQL statements in your Java programs, you must open a database connection. There are two main ways to open a database connection. The first way is to use the getConnection() method of the DriverManager class. The second way uses an Oracle data source object, which must first be created and then connected to. This method uses a standardized way of setting database connection details, and an Oracle data source object may be used with the Java Naming and Directory Interface (JNDI).
I’ll describe both of these ways to open a database connection in the following sections, starting with the first way—which uses the getConnection() method of the DriverManager class.