Here I have tried a lot to explain you by sharing my knowledge
Check the blog below to learn a lot deeper about JDBC and its connectivity
look for the URL below
https://jdbcexamplewithcomments.blogspot.com/
In this blog I have included the way to check whether a particular user is available in the database if incase the user is not there then some error messages can be displayed