Two things spring to mind.
Firstly, telling us you're getting an "error 500" doesn't give us anything to go on - that could be
anything. You need to give us more details of exactly what the error is, and the stack trace. That should be available in your logs if it's not actually being displayed on the page.
Secondly, all that
Java code should be in a
servlet, not in a
JSP page. Using scriptlets is a very outdated practice, and one of the problems with it is that it makes it much harder to debug.
[This may or may not be a database issue, and if it isn't it would be much better off in a different forum - but I can't tell without details of what the error is.]