16.6 Java Database Connectivity with DAO Example

Java

Video is ready, Click Here to View ×


In computer software, a data access object (DAO) is an object that provides an abstract interface to some type of database or other persistence mechanism.

By mapping application calls to the persistence layer, DAO provide some specific data operations without exposing details of the database.

JDBC is a Java database connectivity technology (Java Standard Edition platform) from Oracle Corporation.

This technology is an API for the Java programming language that defines how a client may…

18 thoughts on “16.6 Java Database Connectivity with DAO Example

  1. Any idea why i get this error?

    if i add "return s" within the try/catch block i get the following error on this class level:

    "This method must return a result of type Student"

    If i move this "return s" outside the try/catch the errors dissapears.
    Then "Student s = new Student();" i place before the try/catch.

    no errors:

    class StudentDAO {
    public Student getStudent(int rollno) {

    Student s = new Student();
    try {
    s.rollno = rollno;
    Class.forName("com.mysql.jdbc.Driver");

    } catch (Exception ex) {
    System.out.println(ex);
    }
    return s;
    }
    }

  2. hi navin ,I have a question how to get all data from table I mean "select * from student;"I tried but I am getting an error can you solve this public List<Student> studentList() {try {    Student s = new Student();   String query = "select * from student";   Statement st = con.createStatement();    
       ResultSet rs = st.executeQuery(query);      rs.next();    String name = rs.getString(1);  s.name = name;  st.close();   con.close();  return s;}catch (SQLException e) {System.out.println(e);}return null;}   
    thankssravanthi

  3. im not able to understand this video, sorry to say this sir, ur voice is low, and much confusing , but upto this am learn java only ur videos easly, im learning Java first time, not  IT student , but i wants to get a good job in Java, can u able to feel my feelings . thanq sir.

Leave a Reply

Your email address will not be published. Required fields are marked *