views:

336

answers:

5

Since I've started using NetBeans, I've learned of some powerful ways to abstract away the process of creating Java database applications with automatically generated UI, beans bindings, and a bunch of other stuff I only vaguely understand the workings of at the moment (I hate being a newb). Problem is, how do I do the basic stuff I actually want to do? The tutorials I've read make a big deal about being able to connect to and mess around with a database from within the IDE, or how to create and bind some UI sliders and checkboxes to table columns, etc. But where can I learn about how to make my own code do that stuff? Abstraction is nice and all, but it's quite useless to me at the moment for what I need done.

Can anyone refer me to some good resources or tutorials to learn this? The few I've found aren't proving as useful as I'd hoped to get my project underway...

+1  A: 

Try the JDBC introduction from Sun.

John Topley
+4  A: 

The JDBC Tutorial is a good starting point

A snippet from the intro

The JDBC API is a Java API that can access any kind of tabular data, 
especially data stored in a Relational Database.

JDBC helps you to write java applications that manage these three programming 
activities:

   1. Connect to a data source, like a database
   2. Send queries and update statements to the database
   3. Retrieve and process the results received from the database in answer to 
      your query

      The following simple code fragment gives a simple example of
these three steps:
  Connection con = DriverManager.getConnection
             ( "jdbc:myDriver:wombat", "myLogin","myPassword");

  Statement stmt = con.createStatement();
  ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
  while (rs.next()) {
    int x = rs.getInt("a");
    String s = rs.getString("b");
    float f = rs.getFloat("c");
  }
      This short code fragment instantiates a DriverManager object to 
connect to a database driver and log into the database, instantiates a 
Statement object that carries your SQL language query to the database; 
instantiates a ResultSet object that retrieves the results of your query, 
and executes a simple while loop, which retrieves and displays those 
results. It's that simple. 

There is also a book preview on Google Books here.

Vinko Vrsalovic
After having used it, I'm finding now that this is, in fact, NOT the best tutorial. I could be wrong, but after the intro stuff it appears there are parts of the instructions missing that supposedly step through how things work. I had to infer most of it myself before I switched tutorials.
Daddy Warbox
I personally haven't found missing parts, but still, where did you switch to?
Vinko Vrsalovic
I just followed Apache Derby's own guide: http://db.apache.org/derby/docs/dev/getstart/
Daddy Warbox
A: 

After reading jdbc tutorials take some attention to the base concepts: - connection - statement - query - resultset

Db authorisation belongs to conntection, query is the description of "what to do" - fetch data or update, resultset could be updatable(!) in some cases.

maxp
+1  A: 

One you get comfortable with JDBC, you might want to consider using Spring`s support for JDBC. It provides a much nicer API (than the standard libraries) for accessing a database via JDBC

Don
A: 

The last time I looked at the JDBC tutorial, it had a lot of code examples in it that would be a recipe for SQL Injection if they were used in a real app. I had to teach a class on JDBC and I was supposed to use the tutorial, but I had to supplement it with a security lecture.

Licky Lindsay