University of Cincinnati logo and link  
JDBC Concepts
 
  UC ingot
 
  • When using JDBC, we're doing what we've always done in Java - instantiating objects, getting data from objects, etc.
    • Most of the classes we use are found in either the java.sql or javax.sql packages.  Thus, you'll need to import these in you program.
  • You have to tell your program where to find the database with a Database URL.
    • The URL I used in the previous example is quite simple.  Many URLs have more parameters than that, but let's go ahead and break down what we have:

    • jdbc:mysql://localhost/students
      • jdbc: specifies that this is a JDBC URL.
      • mysql: the subprotocol name, which helps identify the driver we'll use.
      • localhost The machine upon which the database resides.  We use localhost because it is on our local computer, but you can use an IP address if you wish.  You can use the IP address of a different computer if your database is on a different computer (as they usually are), or 127.0.0.1 to indicate localhost.
      • students The database name we want to use.
    • In production quality applications, this information is often stored in a separate file, often an XML file, and read from that file at runtime.  Why?
    • You can also specify username, password, and other information in this URL.
 Connections