The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > java.sql  [73 examples] > Retrieving Data  [7 examples]

e251. Getting Rows from a Database Table

A SQL SELECT query is used to get data from a table. The results of the select query is called a result set. This example executes a SQL SELECT query and creates a result set. See also e252 Getting Data from a Result Set.
    try {
        // Create a result set containing all data from my_table
        Statement stmt = connection.createStatement();
        ResultSet rs = stmt.executeQuery("SELECT * FROM my_table");
    } catch (SQLException e) {
    }

 Related Examples
e252. Getting Data from a Result Set
e253. Determining If a Fetched Value Is NULL
e254. Getting the Column Names in a Result Set
e255. Getting the Number of Rows in a Database Table
e256. Getting BLOB Data from a Database Table
e257. Matching with Wildcards in a SQL Statement

See also: Batching    Connections    Database Meta Data    Deleting Data    Drivers    Importing and Exporting    Inserting and Updating Data    Oracle OBJECTs    Oracle VARRAYs    Procedures and Functions    Scrollable Result Sets    Tables    Updatable Result Sets   


© 2002 Addison-Wesley.