Slide 12.5: Registering the JDBC drivers Slide 12.7: Creating a Statement object Home |
getConnection( )
method of the JDBC DriverManager
class.
This method returns an object of the JDBC Connection
class that needs as input a user name, password, connect string that identifies the JDBC driver to use, and the name of the database to which you want to connect. The following signature takes the URL, user name, and password as separate parameters:
getConnection( String URL, String user, String password );Where the URL is of the form:
jdbc:oracle:<drivertype>:@<database>One example is
Connection conn = DriverManager.getConnection( "jdbc:oracle:thin:@172.20.4.9:1521:aero", "scott", "tiger" );The above example connects user
scott
with password tiger
to a database with INSTANCE_NAME
aero
through port 1521 of host 172.20.4.9
, using the thin driver.
conn.setAutoCommit
( false );
Connection
object so it issues a series of changes that have no effect on the database until you explicitly send a commit.
Connection
is separate, and a commit on one has no effect on the statements on the other.