JDBC Basics |
You are now ready to actually try out some sample code. The directorybook.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.htmlBefore 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 namedCreateCoffees.java
. Below are instructions for runningCreateCoffees.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 namedCreateCoffees.class
, which contains the bytecodes translated from the fileCreateCoffees.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 CreateCoffeesWindows 95/NT
javac CreateCoffees.java java CreateCoffees
JDBC Basics |