Trail: JDBC(TM) Database Access
Lesson: JDBC Basics
Running the Sample Applications
Home Page > JDBC(TM) Database Access > JDBC Basics
Running the Sample Applications
You are now ready to actually try out some sample code. The directory book.html contains complete, runnable applications that illustrate concepts presented in this chapter and the next. You can download this sample code from the JDBC web site located at:


http://www.javasoft.com/products/jdbc/book.html
 

Before you can run one of these applications, you will need to edit the file by substituting the appropriate information for the following variables:

url
the JDBC URL; parts one and two are supplied by your driver, and the third part specifies your data source
myLogin
your login name or user name
myPassword
your password for the DBMS
myDriver.ClassName
the class name supplied with your driver

The first example application is the class CreateCoffees , which is in a file named CreateCoffees.java . Below are instructions for running CreateCoffees.java on the three major platforms.

The first line in the instructions below compiles the code in the file CreateCoffees.java . If the compilation is successful, it will produce a file named CreateCoffees.class , which contains the bytecodes translated from the file CreateCoffees.java . These bytecodes will be interpreted by the Java Virtual Machine, which is what makes it possible for Java code to run on any machine with a Java Virtual Machine installed on it.

The second line of code is what actually makes the code run. Note that you use the name of the class, CreateCoffees , not the name of the file, CreateCoffees.class .

UNIX
javac CreateCoffees.java
java CreateCoffees
Windows 95/NT
javac CreateCoffees.java
java CreateCoffees
Previous page: Creating Complete JDBC Applications
Next page: Creating an Applet from an Application