JDBC - Smart Tech Guides

Latest

Hi this is Sravan Kumar from India. SMART TECH GUIDES is a technical blog. it helps you to learn about Java topics, frameworks and tools like Jenkins, GitHub & related explanations, data base related topics. All these Explanations are explained in simple and understandable manner.

Subscribe Us

SMART TECH GUIDES

JDBC

JDBC (Java Database Connection)

Java Application can store the data in variables, objects, collections, arrays and all these data stored in stack and heap memory.

stack and heap memory part of JVM.

JVM is part of RAM.

once the application execution over, the JVM memory of the application will be vanished. because RAM is temporary memory.

Java application has capable to store the values for temporary purpose only, we are unable to store the data permanently.

Generally, if we want to store the data permanently, we use flat files, pen drives, Database system.

Java application can communicate with files, and database system with the help of IO streams and JDBC concepts.



 

 

JDBC Driver

JDBC driver software is bridge between Java application and Database.

JDBC is Java-based technology, JDBC driver converts Java calls(instructions) to Database calls and converting database calls to Java calls.

 

JDBC API packages are

Java.sql packages

Javax.sql packages

Javax.sql.rowset packages

Javax.sql.rowset.serial packages

 


How to communicate JDBC driver with Java application?

 

1) Load JDBC driver class

Class.forname(oracle.jdbc.driver.OracleDriver);

 

2) Establish Connection with database software

Connection con=DriverManager.getConnection(“url”,”username”,password);

 

3) Create Statement

Statement statement = con.createStatement();

 

4) write sql query 

String query = select *from tablename;

 

5) executing query.

ResultSet result = statement.executeQuery(query);

 

6) close connections.


Note: whenever we are working with JDBC we should add JDBC driver jar file to our Java build path.

No comments:

Post a Comment