You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
Functions of the jdbcHelloWorld.java programAlthough jdbcHelloWorld.java is a simple program, it illustrates severalimportant functions:♦♦♦♦Imports the necessary Java classes, including <strong>JDBC</strong> classesRegisters the <strong>JDBC</strong> driverConnects to the databaseExecutes a simple query♦ Outputs the query results to your screenFor detailed information on these functions, see "First steps in <strong>JDBC</strong>" onpage 20.Example of the jdbcHelloWorld.java programThe following is a listing of jdbcHelloWorld.java for the <strong>JDBC</strong> driver://// This example demonstrates a simple <strong>JDBC</strong> application.//// This sample can be used to check the <strong>JDBC</strong> installation.// Run the application and provide connection information for// a demo/jdbc/samples/ Database that you have access to. It will select// and display "Hello World" from the database.//import java.io.*;//// You need to import java.sql package to use <strong>JDBC</strong>//import java.sql.*;class jdbcHelloWorld {public static void main (String args []) throws SQLException, IOException{// Load the <strong>JDBC</strong> driverDriverManager.registerDriver(new ordbjava.jdbc.ordbDriver());// Prompt the user for connect information<strong>JDBC</strong> <strong>Developer's</strong> <strong>Guide</strong>, P25-9504-03 Page 16Chapter: 2. Verifying a <strong>JDBC</strong> Driver installationSection: Check the environment variables