Paul Sturrock reply,
This is covered in Oracle's documentation, all we could do here is repeat what is written. Read the "JDBC Developer's Guide and Reference". If you are still confused feel freee to ask more questions.
follow this
link where most of parts of your question is already covered.