How to open a database connection using JDBC

Describe how to open a database connection using JDBC.

Opening a database connection:

The database connection should be established after registering the drivers. The getConnection is used to open a database connection.
The following code snippet illustrates this:
Connection con;
con = DriverManager.getConnection(url,"scott","tiger");// returns the connection object where url specifies the database server port, ip address,domain name etc.
For ex:
jdbc:oracle:thin:@192.137.63.230:1521:MyCompany
The ip address is an imaginary one and not intended to specify any specific system. The “scott” and “tiger” are the user name and passwords respectively.
How to send SQL statements to databases for execution?
JDBC : How to send SQL statements to databases for execution? - The following illustrates with examples, to send SQL statements to databases for execution:...
What is a “dirty read”?
What is a “dirty read”? - In typical database transactions, one transaction reads changes the value while the other reads the value before committing or rolling back by the first transaction...
Cold backup, hot backup, and warm backup recovery
JDBC - Cold backup, hot backup, and warm backup recovery - Cold backup is a recovery technique, in which the files must be backed up before the database is restarted at the same time...
Post your comment