1 / 17

MSIS 6 55 Advanced Business Applications Programming

Learn how to use JDBC to connect to databases, query data, and display results in a JTable. This tutorial covers the basics of JDBC, including setting up the driver, creating a connection, executing queries, and displaying results.

jessiew
Download Presentation

MSIS 6 55 Advanced Business Applications Programming

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Week 14 Accessing Databases with JDBC MSIS 655Advanced Business Applications Programming 14.1

  2. Introduction • RDBMS • Relational database management system • MySQL • Open source • Available for both Windows and Linux • http://dev.mysql.com/downloads/mysql/5.0.html • JDBC • Java Database Connectivity • JDBC driver • Enable Java applications to connect to database • Enable programmers to manipulate databases using JDBC • http://dev.mysql.com/downloads/connector/j/5.0.html

  3. Fig. 25.11 | Table relationships in books.

  4. Manipulating Databases with JDBC • Connect to a database • Query the database • Display the results of the query in JTable

  5. Loads the class definition for the database driver. Declare and initialize a Connection reference called connection. Imports the JDBC classes and interfaces from package java.sql Declare a String constant that specifies the JDBC driver’s class name Declare a String constant that specifies the database URL

  6. Extract the contents of one column in the current row Obtain column name using method getColumnName Use the Statement object’s executeQuery method to execute a query that selects all the author information from table authors.

  7. Close the Statement and the database Connection.

  8. Querying the books Database • Allow the user to enter any query into the program • Display the results of a query in a JTable

More Related