there are
alot of sample in the web .
but as an example here :
take a look at this code :
this will connect to mysql
the rule are the same for sql server and oracle .just driver and url will be different.
the above class is almost a complete class for jdbc connection management.
for more information look at :
http://www.javaolympus.com/index.jsp