I see you just started practicing JSP's, but you would need to follow guidelines Armitage mentioned above.
First thing move the code off JSP to a servlet or server side
java class to execute the logic, which will show you the problem clearly.
Are you expecting a lang to be saved to DB, when you access this JSP by URL? lang would get saved to DB only when you submit this page.