Based on javabean clas can i create DAO CRUD methods

i have java bean with setters and getters method;based on i want to create DAO class which includes CRUD methods(create,read etc)
LVL 20
chaitu chaituAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DAO class should not be having any business logic in it, it will just take care of the data access,

you give a query, it will execute it .. thats all about it,

have a layer above your DAO to put your Business Logic, ( CRUD )
you can use your java bean class as a value object.
write a seperate DAO class having insert, update, delete... and
always use your java bean class for setting the values required/returned for/by DAO class
chaitu chaituAuthor Commented:
there is misconception here;i asked i want to generate DAO code based on some DB tables;
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

Suppose if you have a table Employee, and a Employee Bean

do you mean to say, your DAO class should contain methods like,

createEmployee ( Employee e)
Employee getEmployee ( Sting id )
deleteEmployee ( Sting id )
updateEmployee ( Employee e )
chaitu chaituAuthor Commented:
in createEmployee  method create query should construct with all the table columns
>> in createEmployee  method create query should construct with all the table columns

use a insert query,

createEmployee ( Employee emp )
 PreparedStatement ps = con.prepareStatement ( "insert into employees values ( ?, ?,?,.....?) " ) ;
 ps.setString ( 1 , emp.getID () ) ;
 ps.setString ( 2, emp.getName () ) ;
 ps.executeUpdate () ;

similarly for others,
Consider using some ORM solution like Hibernate, JDO...

So that you can map your Java bean to database table in an config file or using Annotations
& then use the ORM tool provided API to persist or query these objects..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.