//data access object

package dao;
import dto.UserDto;
import dbconn.*;
import java.sql.*;

public class UserDao {
    int i=0;
    public int addUser(UserDto user) throws SQLException,ClassNotFoundException{
        int i=0;
        try{
            Connection con= GetConnection.getConnect();
            String query="insert into udetails(name,email,password,address) values(?,?,?,?)";
            PreparedStatement ps= con.prepareStatement(query);
            ps.setString(1, user.getName());
            ps.setString(2, user.getEmail());
            ps.setString(3, user.getPwd());
            ps.setString(4, user.getAddress());
            i=ps.executeUpdate();
        
            con.close();
        }
        catch(Exception e){e.printStackTrace();}
        
        return i;
    }
}
