Generally , we are not supposed(adviced) to write Data Base access code inside any Jsp..! Better way is to acces date base in any Bean(other java class) and pass that bean to jsp. access variable of that class in the jsp..!
(general syntax is Instantiate bean in servlet....!
set that bean as a attribute to request object..! DataBean databean=new DataBean();