• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

First connection, I want to do it !!!

 
Rodolfo Brito
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am a new Java programmer, I never had the satisfaction of conect
one java aplication to a database... I really want to do this. Does anybody has a little and didatic application, so I can make it run on my machine ?

Thank you !
 
Wayne L Johnson
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great starting place: Sun's JDBC tutorial.
That said, here's a VERY simple program that shows some of the basics:

You have to create a connection by registering the databse driver, and then supplying a url (connection information), user and password. You create a statement and pass it a query you want to execute. Finally you loop through the resultset and do what you want with the information. And don't forget to close everything when you're done, shown here in the "finally {}" block.
The driver and the database URL will differ depending on what database you hit, but most drivers come with sample code and documentation showing you how that's down.
Just play around a bit until you get comfortable. Good luck!
[ November 07, 2003: Message edited by: Wayne L Johnson ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic