Java Database Connectivity
Java JDBC is an API that enables java applications to connect with relational databases like MySql.
It can access data of relational database where you update, detete , fetch , store the data from database.
1. JDBC-ODBC Bridge Driver -JDBC drivers coverts the interface calls to ODBC calls, then ODBC bridge calls ODBC driver of the respective database. But this driver have some problems to overcome this thin driver is introduce.
2. Native API Driver - Native API Driver part is replaced by ODBC part, thi driver converts the jdbc method calls into native method calls
3. Network Protocol Driver(Middleware Driver) - In this, first java method calls send to middleware. With the help of middleware then connects to the database on behalf of JDBC Driver.
4. Database Protocol Driver(Pure java driver) or thin driver - Thin driver is most used driver. It directly coverts the JDBC methods calls to the database.
Steps to set-up JDBC Connection
1. Import JDBC packages
2. Load JDBC drivers
3. Open a connection to the database
4. Create statement
5. Execute Query
6. Get resultSet and process it
7. Close connection
Program to create a new file
In this program, we are creating a new file, If same name of file is already exist then it will give us error otherwise it will successfully created.