JOB - Java Objects Builder
TETRACTYS Logo
Jars Resources
  • Home

    JOB

  • Home
  • About
  • FAQ
  • Examples
  • Changes
  • Download
  • JOB Examples of Use
    How to query a database
    This example shows how to query a database using the SQL capabilities of Java. This example uses the JdbcOdbcDriver (for the Windows 95 OS), but it's simple to convert it for a different driver. Follow the instructions:

    Action Screen
    To call the database driver
    Select the class sun.jdbc.odbc.JdbcOdbcDriver Appears
    JdbcOdbcDriver
    LEFT click on the icon Appears the Class Popup Menu of JdbcOdbcDriver
    Click on JdbcOdbcDriver Appears
    JdbcOdbcDriver
    To build a Connection to the database you need a Properties object
    Select the class java.util.Properties Appears
    Properties
    LEFT click on the icon Appears the Class Popup Menu of Properties
    Click on Properties Appears
    Properties
    To build the Connection to the database
    LEFT click on the JdbcOdbcDriver Object icon Appears the Class Popup Menu of JdbcOdbcDriver
    Click on connect(String,Properties) Appears a dialog
    Input the name of the database (for example "jdbc:odbc.database_name") and confirm the other arguments proposed by JOB Appears
    connect
    LEFT click on the connect Object icon Appears the Class Popup Menu of Connection
    Click on getMetaData Appears
    getMetaData
    LEFT click on the getMetaData Object icon Appears the Class Popup Menu of DatabaseMetaData
    Now you can inspect the connection features using the methods of DatabaseMetaData
    LEFT click on the connect Object icon Appears the Class Popup Menu of Connection
    Click on createStatement Appears
    createStatement
    LEFT click on the createStatement Object icon Appears the Class Popup Menu of Statement
    Click on execute(String) and input the SQL string to query the database (for example "SELECT * FROM table_1") Appears
    true

    on success
    LEFT click on the createStatement Object icon Appears the Class Popup Menu of Statement
    Click on getResultSet Appears
    getResultSet
    Now you can inspect the results of the query using the methods of ResultSet

    Back to JOB Examples of Use


    JOB - Java Objects Builder
    For more information
    send an email to
    TETRACTYS Software
    Copyright © 1999 Leonardo Boselli
    All Rights Reserved. Legal Terms.