• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java accessing a database?

 
Jason Batchelder
Ranch Hand
Posts: 37
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can Java do it? If it can how do you go about doing it. For a final project for my class in Java(beginners), I want to have a program access and put information into and pull from a MySQL database then use that information to run the program. It's not really necessary for my idea but it would make the program a lot more user friendly.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The JDBC API, part of J2SE, is Java's database access API. Accessing MySQL is as simple as installing the Java driver distributed with MySQL and using this API.

We have a JDBC forumm here at the Ranch. I'm going to move this thread there, and perhaps other folks will give you more "getting started" tips.
 
shahabas shabeer
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is a good place to start with.

Shahabas E Shabeer
 
Steven Bell
Ranch Hand
Posts: 1071
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may also want to check out one of the DB Frameworks available. I personally use hibernate on a couple of projects and really like it.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65342
97
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First things first. I'd get a good understanding of JDBC under my belt before diving off into something like Hibernate.
 
Pj Murray
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suggested above, you should start by finding out more about the JDBC API.

There's some good links above.

http://www.onjava.com/pub/a/onjava/excerpt/javaentnut_2/index1.html


Then you need to look at the area of data persistence and best practices. I suggest starting with a quick introduction to the J2EE Core Design Patterns before focusing on Data Access Objects.

http://www.corej2eepatterns.com/index.htm

http://www.corej2eepatterns.com/Patterns2ndEd/DataAccessObject.htm


At this stage, you've probably done enough to get full marks in your project.

A further step is to consider the technology choices available (JDBC DAOs, EJB CMP, JDO, Hibernate, etc). The final stage is perhaps the most difficult - you can read about some of the main choices here:

http://www.codefutures.com/weblog/corporate/archives/2005/02/data_persistenc.html


PJ Murray
CodeFutures Software
Java Code Generation for Data Persistence
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic