Check out example codes for "check if sqlexception is duplicate entry java". It will help you in understanding the concepts better.

Code Example 1

try{
...
}catch(SQLException e){
	if(e.getErrorCode() == 1062 ){
	//duplicate primary key
    }
}

Learn ReactJs, React Native from akashmittal.com