代码名称:Java Database Programming Example Code
代码内容:
Version 2.2 - JDK 1.1.4, mSQL-JDBC Beta 1 Release
Hello,
Welcome to the Java Database Programming example code version
2.2, which includes a number of enhancements and some bug fixes. It is a
drop-in replacement for the original examples available from the book´s
Companion Web Site.
Enhancements:
=============
Version 2.2 - JDK 1.1.4, mSQL-JDBC Beta 1, jConnect
* All examples have been tested with Beta 1 of the mSQL-JDBC driver. The
only major change here is that the package name was changed from:
COM.imaginary.sql.msql.MsqlDriver
to:
com.imaginary.sql.msql.MsqlDriver
The examples will not work with earlier versions of the driver unless
you change the package name back to COM.imaginary.sql.msql.MsqlDriver.
* The examples have been tested with Sybase´s jConnect beta that can be
freely downloaded from their web site.
The transaction isolation example in apb/ does not appear to work with
jConnect.
AS WITH DRIVERS SUCH AS mSQL-JDBC, IF YOU DO NOT HAVE THE jConnect
DRIVER INSTALLED, PLEASE COMMENT OUT THE Class.forName() INVOCATION
THAT APPLIES TO IT AND RECOMPILE THE EXAMPLE BEFORE RUNNING IT.
Please check the docs/ directory included with jConnect for any weird
errors you get. I only say this because I´ve encountered a couple of
weird things, and found the answer in that directory. So that you don´t
have to trip over them, here are those weird things:
* You can´t do anything with DatabaseMetaData until you install the
sql_*.sql stored procs in the sp/ directory. This will be either
sql_anywhere.sql or sql_server.sql depending upon whether you are
using SQL Server or SQL Anywhere.
* You have to give a cursor a name with stmt.setCursorName() before you
can use it. See eg/ch03/jdbc_positioned_update.java
As an upshot of having tested these examples with Sybase System 11,
the examples apb/ no longer depend upon the pubs database. However,
some of the examples now rely on a table (food) being created in the
max_price_sp* scrīpt, so run that first.
* isql scrīpts are now included for both Unix and Win32. isql doesn´t
seem to be as forgiving of crlfology as other programs.
* apb/ examples no longer have hardcoded URLs and username/passwords, so
you´ll need to supply them on the command line. For SQL Server
examples, I created a database called javadb, and a user called javadb
who has all rights to the javadb database. This works pretty well for
all examples that use SQL Server.
YOU SHOULD ALSO RUN THE isql scrīptS AS THIS USER, as they no longer
grant special permissions to any particular user.
You can probably create the user by logging in as the sa, and executing
the following commands:
create database javadb
go
use javadb
go
sp_addlogin javadb, javadb, javadb
go
sp_adduser javadb
go
grant all to javadb
go
* Chapters 6 and 7 examples are now deprecated - the source code for both
of those is available in the "unbundled" tinySQL engine, available at:
http://users.ids.net/~bjepson
No further enhancements or bug fixes will be made to the tinySQL engine
in ch06 or ch07 - all of the functionality is available in the
unbundled package, and bug fixes and enhancements will appear in that
package.
The next release of this code will probably do away with the ch06 and
ch07 directory, replacing that with the contents of the unbundled
tinySQL kit.
* Microline no longer makes their toolkit available for download. That´s
OK, since JavaSoft has prerelease versions of JFC available. JFC, also
known as Swing, includes a tree and grid component that the chapter 5
examples now use. You can download JFC at:
http://www.javasoft.com/products/jfc/index.html
Keep in mind that Swing is in a state of flux. The chapter 5 examples
were tested with Swing 0.5.1. As Swing evolves, some things may stop
working, or new features may come into being. I´ll try to keep up with
the changes, and release new code as necessary.
Version 2.0 - JDK 1.1
* The JDBC examples now work with JDK 1.1 - you should not install JDBC or
the JDBC-ODBC bridge, as the are included with the new JDK. To use the
examples with mSQL, use the newest version of George Reese´s mSQL-JDBC
driver, as of this writing, 0.9.6, which is designed for the new JDK.
Version 1.21
* JDBC examples now work with JDBC 1.21, and correspondingly, require the
JDBC 1.21 driver manager, the JDBC 1.2001 JDBC-ODBC bridge, and version
0.9.4a of the mSQL JDBC driver (available from
http://www.ids.net/~bjepson/javadb) to be installed.
Version 1.10
* The MsqlJava examples have been updated to work with version 1.1.3 of
MsqlJava, which moves all of the Msql classes into the msql.* package.
* JDBC examples now work with JDBC 1.10, and correspondingly, require the
JDBC 1.10 driver manager, the JDBC 1.1000 JDBC-ODBC bridge, and version
0.9.4 of the mSQL JDBC driver.
Bug Fixes:
==========
Version 2.2 - JDK 1.1.4, mSQL-JDBC Beta 1, jConnect
In apb/jdbc_dmd.java, I was calling getMetaData() on the first ResultSet
when I should have been calling it on the second.
Version 2.1 - JDK 1.1.2 Release
Upgraded grid and outline examples to JDK 1.1.x AWT model.
Cardfile still produces deprecation errors, but works.
Changed Class.forName() invocations to load mSQL-JDBC
driver from its new package. You should ensure that you
use the latest version of this driver.
Version 2.0 - JDK 1.1 Release
Fixed deprecation bug with StringBufferInputStream in tinySQL.java.
Fixed an error in textFileTable.java where the column size was being
stored as a double value converted to a string. This was causing a
cryptic exception - 10.0 to be displayed. Also fixed the reporting
on this error so the number format exception would be displayed if it
ever happened again.
Version 1.21
Fixed this document to point users to the correct version of the JDK, JDBC,
and the mSQL-JDBC driver.
Version 1.10
Changed some bugs where the cardfile object was referred to as "rolodex."
Changed subdirectory names for the appendix examples to reflect the actual
appendix to which they correspond.
Other Things:
=============
* Some changes have happened in JavaLex (now JLex) and possibly JavaCup, that
I haven´t entirely caught up with in the chapter 6 (tinySQL) stuff. That
being said, these items are taken care of in the unbundled tinySQL
package available at:
http://users.ids.net/~bjepson
It´s very likely that ch06 and ch07 will go away, and be replaced by this
distribution. I´m basically trying to avoid maintaining two nearly
identical code trees.
* The appendix C stuff has been changed to catch up with the JLex change.
The only thing you need to worry about is that the instructions on page
442 are no longer valid. You should change:
java JavaLex scanner.lex
to:
java JLex.Main scanner.lex
* The test.pl scrīpt is included. You should be able to run this through
the Perl (version 5.001 or greater) interpreter, and give it the name of
the directories you want to test as a parameter:
perl test.pl ch01 ch03
It´s worth noting that some examples require a URL, which is the variable
$URL at the top of the scrīpt. You´ll need to set this in the scrīpt
appropriately.
If you want to test all of the examples, you can give it the "all"
parameter:
perl test.pl all
You can also put ´recompile´ on the command line, which will force the
recompilation of each program as it is run:
perl test.pl all recompile
Some of the tests report failure spuriously, since JDK 1.1 now prints out
"Loading..." messages for the properties. This gets intercepted by the
perl scrīpt instead of the expected output.
Before you run the test scrīpt on the chapter 9 example, make sure you´ve
created the tables using the schema.sql scrīpt.