Join David Gassner for an in-depth discussion in this video Getting column and data type information, part of Java Database Integration with JDBC.
- View Offline
I have previously described how to use the database metadata class to get a list of tables from a database.…I'm working in a new version of that project named TablesAndColumns where I already have…the code to get the list of tables.…I'll test it and make sure that I'm successfully retrieving that information.…Now I'm going to show you how to get more information from the metadata object, including…the names and data types of the database columns.…I'll start by re-factoring this code.…Instead of immediately outputting the name of each table, I'm going to store the names…of the tables in an array list.…
I'll start by declaring an array list at the top of the code, I will place my cursor before…the try catch block, and I will declare my ArrayList, and I will set its data type to…String, that is that's the data type of the items it will contain.…And I will name it tables.…I will instantiate it with the ArrayList class's no arguments constructor.…Now I'll go down to the while loop, where I am looping through the result set of the tables.…
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