Connection
In this chapter you will learn:
Connection Object
The Connection
object has the following capabilities:
- Creates SQL statements
- Executes SQL queries, inserts, updates, and deletes
- Handles commits and rollbacks
- Provides metadata regarding the database connection
By default, a Connection object is in autocommit mode, which means it automatically commits changes after executing each statement.
Connection Object Requirements
Parameter | Description |
---|---|
driverName | JDBC driver |
dbURL | Database URL (uniquely identifies a database) |
dbUsername | Database username |
dbPassword | Database user password |
Closing JDBC connections
At the end of JDBC program, we have to explicitly close all the connections to the database in order to save system resource.
We can close a connection by calling the close()
method associated with connection object.
conn.close();
Next chapter...
What you will learn in the next chapter:
- How to pass in parameters with Properties to JDBC Connection
- Passing 'user' and 'password' Parameters as a java.util.Properties Object to Connection object
- Test to See if Your Connection is Alive
Home » Java Tutorial » Driver and Connection