A jsp is compiled into a servlet and then executed, so there's no technical difference.
But in practical terms, a jsp exists to generate a web page. A servlet does work on the server, but will usually pass control to a jsp to display something to the user.
As far as the database code goes, I personally like to keep it out of the jsps. In a three tier model, the jsps are the presentation layer and the servlets are the middle or business layer (with the database itself as the final layer). I put the database code in the middle layer, in the servlets.