Hi Kamala,
I have achieved this functionality using microflow. Please find an snapshot of a microflow. Here I am passing my student object to this microflow,I am checking the username and password in student object is already exist in database using loop.
Create a custom login form by using the tools provided in the modeler.
Set page 1 as the homepage for a userrole, authentication will provide the error message by default.