How to write code in Java Beans for accessing databases in case of MVC?

See the JDBC tutorial track of the Java tutorial.
When you master that, look at things like JPA and Hibernate as nicer ways to abstract away the raw database access code.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.