Basics of JDBC connectivity

JDBC connectivity:
Or simplified as Java database connectivity.What is the fun when the program does not have a database to store to.So,here comes sql(a console based language specially for the data storage) to the rescue.
Why is JDBC connectivity needed:Suppose you are working on large project called Library management and there are huge data to be stored and retrieved during the program execution.Such large data cannot be managed by simple file based databases.So,there is a need for a proper tool for this purpose.JDBC serves for this purpose. 
How to do JDBC connectivity:
First you will need jar file for JDBC driver.
Link:JDBC driver for Mysql.
If you are working on the eclipse,the right click on the project->project properties->java build path->(Bottom Left)add button->Path of the .jar file.
Or you can create lib folder in your project and paste the jar file into it.That shoul work.
JDBC connectivity is done in for steps:
  1. Loading the class with class.forName() method.
  2. Esablishing the connection with getConnection() method.
  3. Giving the query the database.
  4. Getting the result.
There must be four variable needed:
  • Connection conn 
  • Statement stmt
  • String query
  • Resultset result

Comments

Popular posts from this blog

Four building blocks of Object oriented programming language

Exceptions and exceptional handling

Lists in java