Without data from a database, business applications really don't do much. To take your Java experience to the next level, you should have database connectivity. There are still a lot of custom built DOS-based applications that are using xBase database technology, like dBASE, Fox Pro and Clipper. You're trying to convince your company to wake up and smell client/server, that Java can work as a database client and you can keep your data in their existing database format. The solution is using Sequiter Software's CodeBase database management library.
Your manager has decided that your department is going to start using Java as your standard development language. It sounds simple enough, until you start to wonder how you're going to connect Java to your xBase databases to use.
CodeBase is a management program for high-performance data access within a very small memory footprint. It uses Java and others such as C/C++, Visual Basic and Delphi. This means that no matter what your development environment is, you only have to learn one database object model. Its library is designed for single-user, multi-user and client/server environments. Whether you are developing for one user, one department or one enterprise, you are covered with CodeBase. For developers who have a tendency to rely on custom controls, CodeBase includes 16-bit VBX and 32-bit OCX data-aware controls.
CodeBase Versus JDBC
With the big push to marry Java to databases, the question of JDBC (Java Database Connectivity) comes up. Why should you use CodeBase instead of JDBC? JDBC can be used instead of CodeBase provided that you are 1) using JDK1.1 or greater and 2) have a JDBC-ODBC driver that can connect to an xBase database. Using CodeBase as your method to connect to your database, it doesn't matter what version of the JDK you're using because CodeBase doesn't need any particular version of Java. You also won't need to invest in a JDBC-ODBC driver because CodeBase is your driver.
In addition to the multiple language support, you also get all the source code for the C/C++ and Java libraries. This protects your investment in CodeBase because it allows you to rebuild the library with any changes you might need for your organization. It also means that you don't have to wait for Sequiter to come up with a new release of the CodeBase engine. You can get the code fixes from Sequiter, apply it to your source code and rebuild it. You won't lose any of your library customization because you're in control of the source code. Lastly, you get a report writer and code utility.
CodeBase comes with a report writer and a database administration tool. The report writer, CodeReporter, is a report design tool writer with all the standard features of most report writers, like designing a report by painting the layout on a form, Print to Screen, subtotal and total and so on. The database administration tool, Code Util, allows you to do analysis and maintenance on your database. The two significant features CodeUtil has are the Backup and Restore features. CodeBase keeps track of all changes to your database in a log file. If the database becomes damaged, Code Util, using the log file, can restore all the data. It also has a database analysis tool that creates reports on your database activity.
With all the development language support and utilities, you probably think that your shelf will be laced with manuals. Sequiter does provide you with all the manuals, but they thought ahead and they are in the Adobe Portable Document Format (PDF). This makes finding the information you need very easy because CodeBase installs only PDF files for the languages you are using. If you want to see the manuals, they are all available on the CD-ROM.
The power of CodeBase is in its library. For Java developers, there are four class libraries available. They are Code 4, Data 4, Field 4 and Error 4. There are also some minor classes that support the main four. The Code 4 class is used to connect your Java application to the database server and lock the data files when needed. The Data 4 class contains the methods you will use to retrieve and store information to your data files as well as database index maintenance. The Field 4 class is used to access and store field values within a row of the database. Finally, the Error 4 class provides you with database exception handling. It is also an abstract class based on the Java Exception class.
So what does this all mean and how does this help you? The classes have been broken down into logical units of work. In order to connect your Java applet to your xBase database, you use the Code 4 class. Once a successful connection is established, you use the Data 4 class to actually work with the database. You can open the database, close it, create an index and so on. The methods in the Field 4 class are used to handle the field manipulation of a given row. To provide exception handling, the methods of the Error4 class are used.
CodeBase's Java implementation is based on a simple client-to-server model. CodeBase comes with a server component that will run on your Intel-based non-Unix Web server. The server supports both TCP/IP and IPX/SPX transport protocols, so if you're running a Novell networks you don't have to invest in any TCP/IP Winsock. Your Java applet, the client, will run on your user's Java virtual machine and talk to the CodeBase server. Note: Sequiter will soon have a server component for Unix-based Web servers; it should be ready in the first half of 1998.
Editor's Note: Sequiter Software has informed us that the CodeBase server now supports only TCP/IP. Also, their development plans have changed and they do not know if they will be developing a server component for Unix.
Listing 1 is an example of how you can use CodeBase to access information. It will retrieve the age and date of birth an employee and calculate their age based on their date of birth and compare it with their age in the database.
You will find that CodeBase 6 is a great database management library to help you migrate your xBase systems to a broader platform. It's fast, doesn't require a lot of resources on either the client or server side, and with royalty-free distribution and source code included in the price of the product, you are getting a lot for your money.
About the Author
David Jung is a systems engineer specializing in client/server and distributed database development using VB, Access, SQL Server, Oracle and Internet technology. He has also co-authored several Visual Basic books including "Visual Basic 5 Client/Server How-To" (Waite Group Press). David can be reached at [email protected]
throwsError4, IOException, UnknownHostException
Code4client = newCode4();
client. connect (" ", -1, "user 1", " ");
Data4db = newData4 (client);
Field4doubleage = newField4double(db,"AGE");
Field4datebdate = newField4date(db,"BIRTH_DATE");
Datenow = newDate();
milliAge = now.getTime()-bdate.contents.getTime();
dayAge = (int)(((milliAge/1000)/3600)/24);
System.out.println(bdate.contents + " " + now);
System.out.println("Age in days based on birthdate:" + dayAge);
System.out.println("Age based on age field" + age.contents);