1. JDBC
Java JDBC is a java API to connect and execute query with the database.
JDBC API uses jdbc drivers to connect with the database.
JDBC
2. 5 Steps to connect to the database in java
1. Register the driver class
Class. forName(String className)throws ClassNotFoundEx
ception
2.Creating connection
Connection getConnection(String url)throws SQLException
public static Connection getConnection(String url,String na
me,String password)
throws SQLException
JDBC
3. 3.Creating statement
public Statement createStatement()throws SQLException
4.Executing queries
public ResultSet executeQuery(String sql)throws SQLException
5.Closing connection
public void close()throws SQLException
Why use PreparedStatement?
The performance of the application will be faster if you use
PreparedStatement interface because query is compiled only
once.
JDBCJDBC