Join David Gassner for an in-depth discussion in this video Retrieving a single row as a JavaBean object, part of Java Database Integration with JDBC.
- View Offline
In a previous video I described how to create a JavaBean class to represent the structure of the database table.…The Admin class has one private field for each column of the Admin table and the datatypes…of the class matched the datatypes of the columns.…There are private fields and public getters and setters.…The names match the JavaBean convention where the getters start with the word get and the…setters with the words set and then the rest of the names of the methods match the fields.…The fields can match the database column names, and they do here, but they don't have to.…
Now I'm going to show how to use this JavaBean class to represent a single row of data retrieved from a table.…I am working in a version of my project called RetrieveBean, and in this version of the project…my AdminManager class has a new method called getRow.…The getRow method receives a single argument datatype as an integer.…I have named it to match the database column name Admin ID, and that's the primary key…column of the database table.…
Author David Gassner explains how to choose a JDBC driver and connect to one or more databases. He also provides detailed instructions on reading, selecting, and updating data; calling stored procedures; managing data via JavaBean classes or with prepared statements; and working with metadata.
- Importing a MySQL database
- Connecting to databases
- Handling JDBC exceptions
- Looping through result sets
- Limiting the number of fetched rows
- Filtering data with prepared statements
- Calling stored procedures
- Inserting, updating, and deleting rows with prepared statements
- Using a persistent database connection
- Committing and rolling back transactions