Java Relational Data Base Cloudscape IBM

Monday, February 06, 2006

Java Relational Database Cloudscape IBM


INTRODUCTION.
Cloudscape IBM is a relational database management system written in Java language, that support the JDBC API and follow the SQL standards. Cloudscape IBM can run in Unix/Linux OS, Solaris OS or Windows OS.
Cloudscape IBM is a commercial version of the relational database core Apache Derby of open code. Cloudscape/Derby supports single connection or multiple connection and each connection represents a transaction to the database. Cloudscape/Derby can operate in stand alone environment or in client/server environment.
Cloudscape/Derby is written as a library of Java class and it can be embedded in an application Java, therefore this is installed as part of the application and it does not require additional configuration.

OPERATION MODES.
Cloudscape/Derby can be installed in two operation modes:
a) Embedded mode: In this mode the Java application and Cloudscape/Derby run in the same Java Virtual Machine. This mode is for applications of stand alone user.
b) Network server mode: In this mode Cloudscape/Derby processes requests to the application from different Java Virtual Machines. This mode is for applications client/server. For example, Cloudscape/Derby would run in an application client/server with server software like Apache Geronimo.

INSTALLATION.
To use Cloudscape/Derby is necessary:
1) Install J2SE (Java 2 Platform, Standard Edition). Derby works with any certified Sun or IBM J2SE's of 1.3 or higher.
2) Install Cloudscape IBM 10.1
3) Develop and run a database java application considering the operation mode of Cloudscape (embedded mode or Network server mode.) Therefore, there are embedded applications or client/server applications.

COMMENTS.
1. When you download the software on the Internet such as J2SE (JDK) of Sun Microsystems or IBM, and Cloudscape IBM 10.1 , you should consider the type of OS that you are using.
2. The environment variables of the OS must be configured, so J2SE, Cloudscape IBM, Cloudscape Workbench, and Eclipse, operate correctly. Please, consult the corresponding manuals for a correct installation.
3. When you installed Cloudscape IBM 10.1, there are applications examples, one for embedded mode (simple) and two for Network server mode (Network Server Sample Programs), and you can do tests with these.

Note: In my personal case, I am beginner in Java programming and Cloudscape, however I am very interesting to know more about these topics. For the previous reason, I looked for a short way to reach the objective of learning Cloudscape, a Java database and I have found a safe way using VMware Workstation 5.5.
With the project "Laboratory of database with Cloudscape IBM 10.1 and VMware Workstation 5.5", I will try to reach the objective of learning a Java embedded database.
Each week (Monday), I will add new information to the "Laboratory of database."
I wish that this information will be useful for other users of the Internet with interest in the topic of Java databases. If you wish to make some observations, they are welcome.

--------------------------------------------------------------

Here, we start the "Laboratory of database with Cloudscape IBM 10.1 and VMware Workstation 5.5. I will add new activities each week.

FIRST WEEK:

1. Some of Theory.

I understand that an application language permits to build specific applications. Also I understand that a real application consists of accomplishing calculations, manipulating information and managing data. On the other hand, it is known that an application language is not designed specifically to manipulate stored data under the control of a database management system.
In relation to Java, I understand that it is a language oriented to objects to build applications to the Web and SQL is a data language to accede to the relational databases, that by itself tends to be insufficient to write real applications.

Checking the Cloudscape example programs, I evaluated that I have not enough knowledge about Java and SQL working together. For this reason, I went to the library on last Thursday, in Mexico City, and I found an excellent book about the topic. If someone has interest to consult it, the book is "Understanding SQL and Java Together. A Guide to SQLJ, JDBC, and Related Technologies" by Jim Melton and Andrew Eisenberg of Academic Press. The authors mention Cloudscape as a real example of Java and SQL working together. In this case Java is the host programming language and SQL is the data sublanguage. Also, the authors indicate that exist several forms of using the traditional programming languages, together with SQL.

1. Embedded SQL. The SQL statements are embedded in a programming language. When they are found during the normal flow of the program, they are executed invoking the functionalities of the database .
2. Language of modules. It allows to join the SQL statements in modules of "pure SQL" that contain procedures including the SQL statements. These procedures are invoked through the use of "call sentences" of the host programming language.
3. Dynamic SQL. Though, it is invoked through embedded normal statements or language of modules, Dynamic SQL permits the execution of SQL statements even when they are not known during the writing process of the application, the statements are implemented partial or totally on the way.
4. Interfaces at call level. They permit to invoke functionalities of SQL from the applications through the call to functions and procedures, some of those process SQL statements and other encapsulate actions that are required frequently, within simple invocations of the interface.

With the previous theory and returning to the project "Laboratory of database with Cloudscape and VMware" would be interesting to develop an application of each kind described previously and to prove it functionally. Other issue interesting would be to prove applications with Cloudscape in heterogeneous environments with a server and workstations in order to prove and develop real applications.

To make the activities described in the previous paragraph with physical infrastructure, implies to have a network with server and workstations, to have personal specialized to support the hardware and software of the net, to request authorizations to install applications in server and workstations, to work inside of the work schedules of the net, etc. In short, very few people have access to these facilities.

The great solution is to use VMware Workstation 5.5 with Cloudscape IBM 10.1 because you do not need net wiring, you do not need personal specialized, you do not need authorizations, you do not need special schedules, to prove or develop applications in heterogeneous environments.

2. What do you need to use VMware Workstation 5.5.?

1. PC or Laptop with:

  • Operating system (Windows 2000 or Windows XP)
  • 15 GB. of free space in the hard drive
  • PC minimal memory of 384 MB (better if it is greater)
  • All the other devices of a normal PC.

Also is possible to use Linux but I don’t know it. If someone do this, I would add the information in the blog.

2. A boot CD with an OS (I recommend to use Windows 2000 professional because it is easy to install in a virtual machine.)

3. VMware Workstation 5.5 software to install in your PC or Laptop.

4. Software to install in the virtual machines such as J2SE of Sun Microsystems, Cloudscape IBM 10.1, Cloudscape Workbench, Eclipse, WinZip, Acrobat Reader, and some other software.

5. Design and test the simplest applications to understand the concepts (Here, would be excellent the support of expert programmers of the Cloudscape Community.)

3. Below, I present 5 basic but important questions and their corresponding answers.

1. How does VMware Workstation 5.5 work?
VMware Workstation 5.5 is an application that creates virtual machines inside of a physical PC, selecting presetting menu options by mouse’s clicks. I will guide you step by step, since there are different options.

2. What characteristics does the virtual machine have?
Each virtual machine has its own devices (they can be configured too) such as:

  • Memory
  • Hard drive
  • CD – ROM
  • Floppy
  • Ethernet card
  • USB Controller
  • Audio
  • Processor

3. What Operating System can be installed in a virtual machine?
We can install all versions of Windows OS, many versions of Linux, Netware and other OS. Please see the VMware Workstation 5.5 Manual to see more information.
In my case, I have installed Windows 2000 professional in my real PC and I will install Windows 2000 professional in the virtual machines.

4. How the software downloaded of the Internet will be installed in the virtual machines?
I recommend you that the software (J2SE, Cloudscape IBM, Cloudscape Workbench, Eclipse and some other software that is needed) will place in one folder with the name that you decide in your PC.
In future activities, you will install the software that you have in your PC folder to a virtual machine by means of a shared folder. This is important and we will explain it later on.

5. How will we implement the Laboratory of database with Cloudscape and VMware?
a) Install VMware Workstation 5.5 in your PC.
b) Create 1 virtual machine with VMware Workstation 5.5.
c) Install software to the virtual machine (Windows 2000 professional, J2SE, Cloudscape IBM, Cloudscape Workbench, Eclipse, WinZip, Acrobat Reader and some other software.)
d) Create 3 clones of the first virtual machine.

e) Setting up the 4 virtual machines (embedded, localhost, client, and server.)
f) Test applications with Cloudscape in different heterogeneous environments, configuring the virtual machines (teams and networking) to reach the learning objectives of the Laboratory.


ACTIVITIES OF THE FIRST WEEK:

1. Place the downloaded software of the Internet in a folder of your real PC with the name that you decide.

2. Install VMware Workstation 5.5 in your real PC. In the VMware terminology, the real PC is named host machine and a virtual PC is named virtual machine. From now on, we will talk about host machine and virtual machines only.
The installation is very simple, please follow the instructions. When the installation ends, there is an VMware icon on the desktop of your host machine. Click on the VMware icon and start VMware Workstation 5.5. in your host machine.

3. Consult the help menu of VMware Workstation 5.5 to answer the following questions.
a) What characteristics and what OS must have the host machine to run VMware Workstation 5.5 ?

b) What is a virtual machine, which are its characteristics and what kind of OS can be installed in it?
c) How can you create a virtual machine?
d) How can you install an OS in a virtual machine?
e) How can you install software in a virtual machine?

Bye for now, we will see the next week!

--------------------------------------------------------------

Monday, February 13, 2006

SECOND WEEK:

Hello friends of the Cloudscape IBM database!
I wish that you had had a good week.

We start here, again.



We have two manuals to consult in the VMware help menu:

  1. The VMware Workstation User's Manual.
  2. The VMware Guest Operating System Installation Guide. The guide to install an OS in a virtual machine.

Additionally, when you are setting an option in VMware, you have a help tag that points directly to the specific theme.

We will see 5 activities this week.


1. Description of the VMware workstation 5.5 window.

Please click on VMware icon of the host machine.

We have our first window of VMware workstation. The window has 5 principal areas:

  1. Above, The principal menu bar. Please see the different options.
  2. Down, next to the menu, there are Different tools such as turn on or turn off a virtual machine, quick switch, etc.
  3. Left, there is the Favorites column. Here we will see the names of the virtual machines or teams. When you have different virtual machines and teams, you can select one virtual machine or team, here.
  4. Right, Work area. Here, we will see the screen of a virtual machine. In this moment we see 3 icons with the options: New Virtual machine, New team and Open Existing VM or Team.
  5. Down of favorite column and Work area, there is a Messages bar. Sometimes there are not messages. When you are working with a virtual workstation or a team and you note a strange behavior of VMware, here there is a message about a specific action to take.

Some important menu options are:

Edit > Virtual Network settings… Here, you can see the different options of virtual networks.

Edit > Preferences. Here, you can see the global configuration of VMware like the default directory of virtual machines or teams, Memory to run the virtual machines, etc.

VM > Clone… Here, there is a wizard that will help you to create a copy of a virtual machine

VM > Settings… Here, there are different options to configure the devices of a virtual machine and other options like shared folders.

Team > Settings… Here, we can set the type of connection of each virtual machine of a team. Also, we can define the time to start each virtual machine of the team.

I use Windows 2000 in my host machine and Windows 2000 in my virtual machines but is possible other combinations like Windows XP in the host machine and Windows 2000 in the virtual machine, etc. Also is possible to use Linux in host machine or virtual machine.

The name of a virtual machine includes the name of the OS more additional words.


2. This is the Work Plan:

We will create 4 virtual machines with the next names:

  1. Windows 2000 with Cloudscape (embedded mode)
  2. Windows 2000 with Cloudscape (NetworkServer mode-localhost)
  3. Windows 2000 with Cloudscape (NetworkServer mode-client)
  4. Windows 2000 with Cloudscape (NetworkServer mode-server)

Remember, if you use a different OS, the names of your virtual machines will include the name of your OS.

First, we will create the first virtual machine with its OS, in this second week.

Second, we will install the software on the first virtual machine (J2SE, Cloudscape, Workbench Cloudscape, Eclipse, WinZip, Acrobat Reader and some other software), the next third week.

Third, we will have the first virtual machine with all software installed and configured the environment variables correctly, to work for Cloudscape embedded mode. After, we will generate clones of the first virtual machine to the other 3 virtual machines (each clone takes 10 minutes to create), the next third week.

Then, we will adapt the environment variables of the clones to NetworkServer mode-localhost, NetworkServer mode-client, and NetworkServer mode-server. Also, we will create teams and networking with the virtual machines. All these, the next fourth week.

Finally, we will test Cloudscape IBM with different applications in heterogeneous environments (stand alone, teams and networking), in this way:

a) Understanding and running a program to Cloudscape in embedded mode, the next fifth week.

b) Understanding and running programs to Cloudscape in NetworkServer mode (localhost), the next sixth week.

c) Understanding and running programs to Cloudscape in NetworkServer mode (client-server team), the next seventh week.


3. Okay. We go to create the first virtual machine.

On VMware workstation 5.5 window:

  1. Click on File > New > Virtual Machine and we have the New Virtual Machine Wizard, then click next
  2. Select Typical and click next
  3. Select Guest Operating System and Version (in my case Windows 2000 professional, but can be other). Click next
  4. Select virtual machine name and location. Please type Windows 2000 with Cloudscape (embedded mode). Location is good. Click next
  5. Select Network type, choose NAT and click next
  6. Select Disk capacity, by default is 8 GB, but change to 4 GB (it is enough to our software), please do not select allocate all disk space now. Click end.

We have created our first virtual machine with the name Windows 2000 with Cloudscape (embedded mode). It has not an OS yet.

In the work area of VMware workstation, there is information about the virtual machine such as the virtual machine name, commands, devices and notes. The commands and devices options can be configured.

Please, double click on hard disk SCSI device and you can see the characteristics of this device. As example and because is better option, we will change the hard disk SCSI to hard disk IDE of our first virtual machine.

In the principal menu of VMware workstation:

  1. Click on VM > Settings… and we have a Virtual Machine Settings window with the devices
  2. Click add button and we have an Add Hardware Wizard
  3. Click next, and we have a new window with Hardware Type to add
  4. Select Hard Disk and click next. We have a new window to Select a Disk
  5. Select Create a new virtual disk and click next. We have a new window to Select a Disk Type
  6. Select IDE and click next. We have a new window to Specify Disk Capacity
  7. Select 4 GB and Split Disk into 2 GB files. Click next, and we have a new window with the Filename default. It is good
  8. Click end and we return to the Virtual Machine Settings window, but now we have 2 hard disks (a SCSI Hard Disk and an IDE Hard Disk)
  9. Click on SCSI Hard Disk to select this, and in the same window, click on remove button. The SCSI Hard Disk is removed
  10. At this time, we have one Hard Disk and it is IDE
  11. Click OK button in the Virtual Machine Settings window and we finish this activity

4. Now, we will install the OS in the virtual machine.

  1. With the virtual machine turn off, insert a bootable CD with an OS in the CD drive of your host machine to install it in the virtual machine that we have created (In my case, I have installed Windows 2000, but you can install another.)
  2. Turn on the virtual machine and follow the instructions to install the Guest OS in the virtual machine. This activity takes 1 hour with Windows 2000 more or less.
  3. When you finish, you have the first window of your virtual machine with an OS installed. There is a strange behavior with the mouse because you need to install VMware tools in your virtual machine with an OS installed.

5. As a final point, install the VMware Tools in the virtual machine with an OS installed.

With the virtual machine running the Guest Operating System:

  1. Select VM > Install VMware Tools of the principal menu of VMware Workstation 5.5.

  2. Please, follow the instructions and when it process ends, you will have a better behavior of the mouse and video of the virtual machine.

ACTIVITIES OF THE SECOND WEEK:

Please, try to practice the next activities:

  • The movement of the mouse inside of the screen of the virtual machine and outside of this. When you need to use the CTRL-ALT-DEL keys, inside of the virtual machine, it is CTRL-ALT-INS and outside of the virtual machine, it is CTRL-ALT-DEL.
  • Turn on and turn off the virtual machine.

Bye for now. We will see the next week!

--------------------------------------------------------------

Monday, February 20, 2006

THIRD WEEK:

Hello fans of the Cloudscape IBM database!
This week is full of activities.
We start here, again.


1. OS installation in a virtual machine.

  1. Please Turn off the virtual machine.
  2. Place the bootable CD with an OS in your CD drive. In my case, I will install Windows 2000 but you can install other.
  3. Turn on the virtual machine.
  4. Start the installation program of Windows 2000.
  5. When you need to type information inside of the virtual machine screen to install the OS, click the mouse inside of the Work area (screen) of the virtual machine. The cursor disappears and you can type inside of the virtual machine. You will do this, several times.
  6. When you need to use the mouse again, click CTRL-ALT and the cursor appears again. You will do this, several times.
  7. When the program installation asks if you want format the hard disk, select yes. There is not problem because the hard disk is of the virtual machine. You do not format the hard disk of the host machine.
  8. Start the copy of OS files to the hard disk of the virtual machine.
  9. The process continues. The virtual machine turns off and turns on several times, automatically. You have not problem because all the process is inside of the virtual machine. It does not affect the host machine.
  10. When the process ends, we have the first window with an OS.
  11. Install VMware Tools. Choose VM > Install VMware Tools... and follow the instructions. Please, select Typical set up type. When the installation ends, you must restart the virtual machine.
  12. Now, the mouse’s cursor works fine inside and outside of the virtual machine, and the graphic behavior of the virtual machine is better.

2. Shared Folder configuration to install other software in the virtual machine.

  1. Select VM > Settings… and we have Virtual Machines Setting window.
  2. Select Options tag and we have a list to set.
  3. Select Shared Folders, go right and click on Add… button.
  4. Start the Add Shared Folder Wizard, click next, and we have new window.
  5. Type the shared folder name. It can be any name. I named the shared folder deposit-1.
  6. Click on Browse… button to localize the folder in the host machine, where you stored the software to install in the virtual machine (WinZip, Acrobat Reader, J2SE, Cloudscape IBM, Cloudscape workbench, Eclipse and other software). I named the folder Open Software but the name can be any name. We need WinZip to unzip some files and Acrobat Reader to read the Cloudscape manuals.
  7. Click next and there is other window with attributes.
  8. Select Enable this share and click end button, and we have the shared folder with the name, host folder and status.
  9. Click on OK button in the Virtual Machine Settings window and we end this activity.

Notes:

  • When you want power off the virtual machine, please check that you have shut down your guest operating system before powering off.
  • When you click on an icon, sometimes is one click and other times is double click.

3. Installation of other software in the virtual machine.

We go to install software such as WinZip to unzip the files, Acrobat Reader to read the Cloudscape manuals, J2SE of Sun Microsystems, Cloudscape IBM, Workbench Cloudscape, Eclipse, and some other software. Remember, all installation activities are with the Guest Operating System of the virtual machine. The installations do not affect the host machine.

  1. Power on the virtual machine and start the guest operating system (in may case Windows 2000 but it can be other.)
  2. Click on My network sites icon of Windows 2000 desktop, and we have a new window.
  3. Click on The whole network icon, and we have a new window.
  4. Click on complete content link, and we have a new window with two icons.
  5. Click on VMware Shared Folders icon, and we have a new window.
  6. Click on \ \.host icon, and we have other window.
  7. Click on \ \.host\Shared Folders and we have the deposit-1 folder.
  8. Click on deposit-1 folder and we have the software to install in the virtual machine.
  9. Now we start the software installation.
  10. Click on the WinZip application icon and follow the instructions to install it.
  11. Click on the Acrobat Reader application icon and follow the instructions to install it (In my case, I have a CD with Acrobat Reader. I place the CD in the CD drive of the host machine. Click on My PC icon of the virtual machine screen. Click on CD drive icon. Click on Acrobat Reader application and follow the instructions to install it.)
  12. Click on the J2SE application icon and follow the instructions to install it. You must configure the system environment variables (PATH and CLASSPATH) of the virtual machine to operate correctly J2SE. Please see the installation file of the application.
  13. Click on the Cloudscape IBM application icon and follow the instructions to install it. After, you must configure the environment system variables PATH and CLASSPATH to Cloudscape embedded mode of the virtual machine. See the note at the end of this activity.
  14. Click on the Workbench Cloudscape application icon and follow the instructions to install it.
  15. Click on the Eclipse application icon and follow the instructions to install it.
  16. You would install other software if you want, considering the capacity of Virtual machine hard disk.

Note:

Windows 2000 with Cloudscape (embedded mode) virtual machine must have the system variables configured, considering the derby.jar and derbytools.jar files. For more information, see the Getting Started with Cloudscape IBM manual (pages 5 to 14) and the Table 1 later on, in this third week.


4. Creating the 3 clones of the first virtual machine.
We invest a lot of work to create the first virtual machine, but now is time to save time and we will create the other 3 virtual machines copying the first virtual machine across the clone option. Each clone takes 10 minutes to create.

  1. Select the virtual machine named Windows 2000 with Cloudscape (embedded mode) in the Favorites column.
  2. Select VM in the principal menu and we have other menu window.
  3. Select Clone… and start Clone Virtual Machine Wizard.
  4. Click next and we have the Clone source window.
  5. Select From current state option.
  6. Click next and we have the Clone Type window.
  7. Select Create a full clone option.
  8. Click next and we have the Name of the New Virtual Machine window.
  9. Type in the virtual machine name option, the name of our second virtual machine that is Windows 2000 with Cloudscape (NetworkServer mode – localhost.) Remember, the name can change if you use other OS in your virtual machine.
  10. The Location option is good.
  11. Click end button and we have a VMware Workstation window with the status of cloning. It takes 10 minutes approximately.
  12. When the cloning… finishes, we have the Clone Virtual Machine Wizard with the status of clone done.
  13. Click done button and we have our second virtual machine with the name Windows 2000 with Cloudscape (NetworkServer mode – localhost.)
  14. Repeat the previous 13 steps to create the other two virtual machines with the names, Windows 2000 with Cloudscape (NetworkServer mode – client) and Windows 2000 with Cloudscape (NetworkServer mode – server.)

When you finish this activity, you have 4 independent virtual machines with the names:

  • Windows 2000 with Cloudscape (embedded mode)
  • Windows 2000 with Cloudscape (NetworkServer mode – localhost)
  • Windows 2000 with Cloudscape (NetworkServer mode – client)
  • Windows 2000 with Cloudscape (NetworkServer mode – server)

Now, the 4 virtual machines have the environment system variables (PATH and CLASSPATH) configured to embedded mode. We must configure the last 3 virtual machines in agreement with its name. Please see the next table.


TABLE 1. The .jar files considering Cloudscape operation mode.

  1. EMBEDDED MODE: Is necessary the derby.jar and derbytools.jar files.
  2. NETWORKSERVER MODE (Localhost): Is necessary the derby.jar, derbynet.jar, derbyclient.jar, db2jcc.jar and db2jcc_license_c.jar files.
  3. NETWORKSERVER MODE (client): Is necessary the derbytools.jar, derbyclient.jar, db2jcc.jar and db2jcc_license_c.jar files.
  4. NETWORKSERVER MODE (server): Is necessary the derby.jar and derbynet.jar files.

There are two operation modes of Cloudscape: Embedded mode and NetworServer mode. Inside of NetworkServer mode there are two options: Client and Server.
Additionally, there is an option in Cloudscape, where is possible to run a client/server application in one machine (Localhost.)

About the .jar files, the Getting Started with Cloudscape IBM manual (pages 5 to 14) says:

  1. The derby.jar file is required to embedded databases.
  2. The derbytools.jar file is required to tools such as dblook, ij and import/export.
  3. The derbynet.jar file is required to start the Network server Derby.
  4. The derbyclient.jar file is required to use the Network driver Derby.
  5. The db2jcc.jar file is required to use the DB2JDBC Universal Driver.
  6. The db2jcc_license_c.jar file is the license file of the Universal Driver.

As a result, we have generated 4 virtual machines to test Cloudscape with different configurations:

  1. Windows 2000 with Cloudscape (embedded mode) virtual machine must have the system variables configured, considering the derby.jar and derbytools.jar files.
  2. Windows 2000 with Cloudscape (NetworkServer mode - localhost) virtual machine must have the system variables configured, considering the derby.jar, derbynet.jar, derbyclient.jar, db2jcc.jar, and db2jcc_license_c.jar files.
  3. Windows 2000 with Cloudscape (NetworkServer mode - client) virtual machine must have the system variables configured, considering the derbytools.jar, derbyclient.jar, db2jcc.jar, and db2jcc_license_c.jar files.
  4. Windows 2000 with Cloudscape (NetworkServer mode - server) virtual machine must have the system variables configured, considering the derby.jar and derbynet.jar files.

ACTIVITIES OF THE THIRD WEEK:

  • Try to configure the system variables for J2SE and Cloudscape IBM, correctly. Please see the installation files.
  • Try to install the correct version of Eclipse to Cloudscape IBM. Install the correct plug-ins Eclipse to Cloudscape IBM. It is an IDE to develop applications to Cloudscape.
  • If you want achieve more goals. Try to configure the last 3 virtual machines considering the previous Table 1 (.jar files.)

Remember, I am learning too. If you see mistakes, please send me a message in the blog.

Bye for now. We will see the next week!

--------------------------------------------------------------

Tuesday, February 28, 2006

FOURTH WEEK:

Hello users of the Cloudscape IBM database!
This week is for virtual machines final tuning and grouping.
We start here, again.



1. Setting up the Java environment (PATH, CLASSPATH), when you install J2SE.
PATH: To run the JVM and Java applications you need to set up your PATH environment variable and the OS will know where to look for the .exe Java files (they are in the bin directory.)

PATH=C:\Program files\Java\jdk1.5.0_05\bin

You can do this if your OS accept the instruction:

set JAVA_HOME=C:\Program files\Java\jdk1.5.0_05 then

set PATH=%JAVA_HOME%\bin

CLASSPATH: To load the Java API's to the memory and use these by the Java compiler and Java interpreter, you need to set up the CLASSPATH environment variable, considering the tools.jar and dt.jar files.

CLASSPATH=.;C:\Program files\Java\jdk1.5.0_05\lib\tools.jar;
C:\Program files\Java\jdk1.5.0_05\lib\dt.jar

You can do this if your OS accept the instruction:

set JAVA_HOME=C:\Program files\Java\jdk1.5.0_05 then

set CLASSPATH=.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOM
E%\lib\dt.jar


2. Setting up the environment (PATH, CLASSPATH), when you install Cloudscape 10.1

The Getting Started with Cloudscape IBM manual (page 7) says that “you can set the CLASSPATH environment variable in the OS either temporarily, permanently, or at run time when you start your Java application and the JVM. If you set the environment temporarily, you must set it each time that you open a new command window. In most development environments, it is best to set the CLASSPATH environment variable temporarily. Derby provide some scripts to help you set your CLASSPATH this way; they are found in the /frameworks/ embedded/bin directory or the /frameworks/NetworkServer/bin directory. To set the CLASSPATH temporarily, run a scrip every time you open a new command window.

Returning to the “Laboratory of database with Cloudscape IBM and VMware workstation 5.5”, we have 4 virtual machines to Cloudscape only. With this facilities to test Cloudscape and to develop applications, I have decided configure permanently the environment variables to Cloudscape in our 4 virtual machines, considering the operation mode (embedded, localhost, client and server), but you can decide your option. Please see the Table 1 in the third week session of the blog.

To test Cloudscape, we will use the applications included when you install Cloudscape.
Embedded mode:
C:\Program files\IBM\Cloudscape_10.1\demo\programs\simple di- rectory with the program SimpleApp.
NetworkServer mode:
C:\Program files\IBM\Cloudscape_10.1\demo\programs\nserverde mo directory with the programs NsSample, NsSampleClientThread, NetworkServerUtil, SimpleNetworkServerSample, and SimpleNetworkClientSample.

To set up PATH and CLASSPATH in Windows 2000 click on start > setting up > Control Panel > System > advanced > environment variables > select PATH or CLASSPATH and edit.


2.1. Setting up the environment variables to Windows 2000 with Cloudscape (embedded mode) virtual machine.

PATH: We need to add the trajectory to the scripts and the trajectory to the application (SimpleApp program.)

PATH=C:\Program files\IBM\Cloudscape_10.1\frameworks\embed ded\bin;C:\Program files\IBM\Cloudscape_10.1\demo\programs\si mple

If set DERBY_INSTALL=C:\Program files\IBM\Cloudscape_10.1 then

set PATH=%DERBY_INSTALL%\frameworks\embedded\bin;%DER BY_INSTALL%\demo\programs\simple


CLASSPATH: We need to add the trajectory to derby.jar and derbytools.jar files.

set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INS TALL%\lib\derbytools.jar


2.2. Setting up the environment variables to Windows 2000 with Cloudscape (NetworkServer mode - localhost) virtual machine.

PATH: We need to add the trajectory to the scripts and the trajectory to the applications (NsSample, NsSampleClientThread, NetworkServerUtil programs.)

PATH=C:\Program files\IBM\Cloudscape_10.1\frameworks\Networ kServer\bin;C:\Program files\IBM\Cloudscape_10.1\demo\program s\nserverdemo

If set DERBY_INSTALL=C:\Program files\IBM\Cloudscape_10.1 then

set PATH=%DERBY_INSTALL%\frameworks\NetworkServer\bin;% DERBY_INSTALL%\demo\programs\nserverdemo

CLASSPATH: We need to add the trajectory to derby.jar, derbynet.jar, derbyclient.jar, db2jcc.jar and db2jcc_license_c.jar files.

set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INS TALL%\lib\derbynet.jar;%DERBY_INSTALL%\lib\derbyclient.jar;% DERBY_INSTALL%\lib\db2jcc.jar;%DERBY_INSTALL%\lib\db2jcc _license_c.jar


2.3. Setting up the environment variables to Windows 2000 with Cloudscape (NetworkServer mode - client) virtual machine.

PATH: We need to add the trajectory to the scripts and the trajectory to the application (SimpleNetworkClientSample program.)

PATH=C:\Program files\IBM\Cloudscape_10.1\frameworks\Network Server\bin;C:\Program files\IBM\Cloudscape_10.1\demo\programs\ nserverdemo

If set DERBY_INSTALL=C:\Program files\IBM\Cloudscape_10.1 then

set PATH=%DERBY_INSTALL%\frameworks\NetworkServer\bin;% DERBY_INSTALL%\demo\programs\nserverdemo

CLASSPATH: We need to add the trajectory to derbytools.jar, derbyclient.jar, db2jcc.jar and db2jcc_license_c.jar files.

set CLASSPATH=%DERBY_INSTALL%\lib\derbytools.jar;%DERBY_ INSTALL%\lib\derbyclient.jar;%DERBY_INSTALL%\lib\db2jcc.jar;% DERBY_INSTALL%\lib\db2jcc_license_c.jar


2.4. Setting up the environment variables to Windows 2000 with Cloudscape (NetworkServer mode - server) virtual machine.

PATH: We need to add the trajectory to the scripts and the trajectory to the application (SimpleNetworkServerSample program.)

PATH=C:\Program files\IBM\Cloudscape_10.1\frameworks\Network Server\bin;C:\Program files\IBM\Cloudscape_10.1\demo\programs\ nserverdemo

If set DERBY_INSTALL=C:\Program files\IBM\Cloudscape_10.1 then

set PATH=%DERBY_INSTALL%\frameworks\NetworkServer\bin;% DERBY_INSTALL%\demo\programs\nserverdemo

CLASSPATH: We need to add the trajectory to derby.jar and derbynet.jar files.

set CLASSPATH=%DERBY_INSTALL%\lib\derby.jar;%DERBY_INST ALL%\lib\derbynet.jar

3. Setting up the environment (PATH, CLASSPATH), when you install Cloudscape Workbench.

When you unzip Cloudscape Workbench 1.0, it creates a new folder with the name csworkbench. I unzipped this in the local disk ( C ) of the virtual machine. To start click on csworkbench icon of csworkbench folder. I did a direct access to the desktop of the virtual machine in the next form: click on csworkbench icon with left button of the mouse and select direct access > click on direct access to csworkbench icon with right button and drag and drop on the desktop of the virtual machine. Now, you can start Cloudscape Workbench of the desktop of the virtual machine.

See the article IBM Cloudscape Workbench by Gilles Roux .

It is not necessary to set up PATH and CLASSPATH for Cloudscape Workbench 1.0.


4. Setting up the environment (PATH, CLASSPATH), when you install Eclipse for Cloudscape 10.1

Eclipse is an open source community whose projects are focused on providing an extensible development platform and application frameworks with exemplary tools that make it easy and cost-effective to build and deploy software.
Please, see the documents and links:

4.1. Eclipse-based tools for Apache Derby by Susan Cline.

4.2. Apache Derby integration.

4.3. Eclipse website.

4.4. Eclipse wtp project website .

4.5. Eclipse release Build 0.7 .


5. Creating teams and Networking with the virtual machines.

VMware Workstation teams allow you to set up a virtual computer lab on one host computer. You can now power on multiple associated virtual machines with a single click.
Team virtual machines can use networking just as other virtual machines can. In addition, team members can communicate in private networks called LAN segments. LAN segments are completely independent of - and invisible to - the host computer's network.
Team settings control the start-up order and timing for team virtual machines. You can set up specific delays between booting virtual machines so the host CPU load is spread out. Teams automatically launch virtual machines in the right order, with delays that you specify to ensure that each virtual machine stabilizes before the next virtual machine boots.
You can use teams to virtualize multitier environments. Start separate client, server and database virtual machines with one click. Configure start-up delay times so clients do not submit queries before the server is ready.

5.1. Making a new team.
Select File > New > Team and start the New Team Wizard > click Next and there is other window > Type Team name (type Cloudscape server-client), Location is good, click Next and there is other window > Add virtual machines to the Team, click Yes and there is other window > click Add button and a drop-down menu appears > Select Existing Virtual Machine option > Open a file browser from which you can navigate the host file system to locate an existing .vmx file (see note 1), add the next 2 virtual machines; Windows 2000 with Cloudscape (NetworkServer mode-server) and Windows 2000 with Cloudscape (NetworkServer mode-client) > click Next and there is other window > Add LAN Segment to the Team, select Yes, click Next and there is other window > click Add to create a LAN segment > click Next and there is a new window to select the network connections for each virtual machine on the team. Select LAN checkboxes of the 2 virtual machines > click Finish button.

Note 1: The .vmx files are in My virtual machines folder of the host machine. Sometimes the name of .vmx file does not correspond with the name of the virtual machine because it was a clone of our first virtual machine. Please, select the equivalent correct name to Windows 2000 with Cloudscape (NetworkServer mode-server) and Windows 2000 with Cloudscape (NetworkServer mode-client). If you can not localize the correct names, suspend Making a new team activity and localize the correct .vmx files for our 2 virtual machines.

5.2 Opening a team.
Chose File > Open and browse the location of the .vmtm file in My Virtual Machines folder > Select the file and click Open.

Note 2: Sometimes a team or virtual machine is not in the Favorites column but you can add this to Favorites column in the next form. In My Virtual Machines folder, select a .vmx file or .vmtm file.
If you want to add a team or virtual machine to the Favorites column, click File > click Add Favorites.
If you want to remove a team or virtual machine of the Favorites column, click File > click Remove from Favorites.
Remember, all teams and virtual machines are in My Virtual Machines folder of the host machine.

5.3 Closing a team.
Each virtual machine of the team must be shut down.
Make sure the team is powered off.
Chose File > Close.


6. Practical tips to manage the virtual machines.
To manage 1, 2 or 3 virtual machines is easy but more than 3 is more difficult because each virtual machine has different OS, or different configuration, or different devices, or different software installed, etc.
This is experience. I have 10 virtual machines and remember the OS, configuration, software installed, and other details of each one is confused.
I have tried to document the virtual machines in three levels to manage easily the virtual machines, and it seems to work fine.

  • Name level. You can assign any name to the virtual machine but is a good custom to include the OS name and other words in relation with the software installed to identify quickly the virtual machine. For example, Windows 2000 with Cloudscape (embedded mode) seems long but you identify the virtual machine quickly.
  • Favorites column level. When you have several virtual machines with the same theme, you can create a new folder to group them. In the area of Favorites column click with right button of the mouse and there is a little window > select New and there is other window > select Folder… and there is other window > type the name of the new folder (Cloudscape in our case) and click OK button and we have the Cloudscape folder. Now drag and drop our 2 virtual machines and 1 team to the Cloudscape folder.
  • Work area level. When you select a virtual machine, the first screen of the virtual machine has a Notes section where you can type notes for the virtual machine or team. I type notes such as the software installed and the versions, format file type of the virtual machine, purpose of the team, etc.

In the future, if you have created 10 or more virtual machines and teams, you can add a physical hard disk (for example 80 GB) to your desktop PC and store there all your virtual machines and teams.


ACTIVITIES OF THE FOURTH WEEK:

  • Cloudscape Workbench. You can read in the help menu, the Cloudscape Workbench user guide to learn themes such as: Connecting to a database, Using the Database Explorer, Creating database objects, Working wit data, Data Output view, Creating, running, and saving SQL scripts, Data Definition Language and Migrating a database.
  • Eclipse. You can read the help menu content. There are Basic Tutorials, Programmer’s guides and Basic Plug-in tutorials. Install the correct plug-ins Eclipse to Cloudscape IBM. Read the article Eclipse-based tools for Apache Derby by Susan Cline. Eclipse is extensive. It is an IDE to develop applications to Cloudscape. I am learning Eclipse too.
  • VMware Workstation 5.5. You can read in the help menu the themes, Configuring Teams and Configuring a Virtual Network to learn more details about these themes.

The three activities include big amount of work, but it would be useful to other projects.
Remember, I am learning too. If you see mistakes, please send me a message in the blog.

Bye for now. We will see the next week!

--------------------------------------------------------------
Tuesday, March 7, 2006

FIFTH WEEK:

Hello developers of the Cloudscape IBM database!
This week is for running programs in embedded mode.
We start here, again.

1. Additional comments about the Cloudscape folder in the Favorites column.
I wanted to test Cloudscape applications in the virtual machines and team but I realized that they need additional simple setting up. Please, remember that we created 1 original virtual machine and 3 clones. The original virtual machine has a password, equipment’s name, and workgroup. The 3 clones have exactly the same information because they are a copy of the original virtual machine. We need to change this information to personalize each virtual machine, especially with the team, because it is a LAN segment.

At this moment, we have a Cloudscape folder in the Favorites column. Please, click on Cloudscape folder and we have 3 icons, 2 for virtual machines (embedded and localhost) and 1 to team (Cloudscape server-client.) The team has 2 virtual machines, server and client.

In relation to the setting up, the password must be different for each virtual machine by security, but this is a test lab and I assigned the same password to the 4 virtual machines for speed. About the equipment’s name, and workgroup, they are necessary to change, especially in the team. This configuration is in agreement with your OS. I am using Windows 2000 and I must setting up the name and the workgroup of each virtual machine in this way:

Windows 2000 with Cloudscape (embedded mode) virtual machine.
Name: PC1
Workgroup: MANUFACTURE

Windows 2000 with Cloudscape (NetworkServer mode-localhost) virtual machine.
Name: PC2
Workgroup: MANUFACTURE

Windows 2000 with Cloudscape (NetworkServer mode-server) virtual machine.
Name: PC3
Workgroup: MANUFACTURE

Windows 2000 with Cloudscape (NetworkServer mode-client) virtual machine.
Name: PC4
Workgroup: MANUFACTURE

I named the virtual machines (PC1, PC2, PC3 and PC4) and the workgroup (MANUFACTURE) but you can assign any other name.
To set up Windows 2000, click on start button > setting up > Control Panel > System > Network identification > Properties > and type equipment’s name, and workgroup.

2. Understanding and running a program to Cloudscape in embedded mode with a virtual machine.
We need two elements to make this activity:
1. A computer loaded with J2SE and Cloudscape IBM 10.1.
2. A program developed to Cloudscape embedded mode.

In the lab, we have a virtual machine setting up especially to embedded mode and it is Windows 2000 with Cloudscape (embedded mode.)
Also, there is a SimpleApp program to embedded mode in the simple folder of Cloudscape_10.1 directory, in the virtual machine.

2.1 Understanding the SimpleApp program.

In embedded mode, the application starts up an instance of Derby within the current Java Virtual Machine and shuts down the instance before it completes. No network access is involved. Only one application can access a database at a time.

I will try to explain the program to myself and I think it would be interesting to other people with interest in the theme.

The sequence to explain the program is:
First: A statement or code lines or conclusion of the SimpleApp program.
Then: Official documentation of JDK 5.0 and Cloudscape IBM 10.1.

1. Statement: The SimpleApp program is a JDBC application.
Documentation:
The JDBC API provides universal data access from the Java programming language. Using the JDBC 3.0 API, you can access virtually any data source, from relational databases to spreadsheets and flat files. JDBC technology also provides a common base on which tools and alternate interfaces can be built. The JDBC 3.0 API is comprised of two packages:
a) the java.sql package.
b) the javax.sql package, which adds server-side capabilities.
You automatically get both packages when you download the Java 2 Platform Standard Edition 5.0 (J2SE.)

2. Conclusion: The program import 3 Java interfaces, 1 Java class, and 1 exception of the Java.sql package.

Interfaces: Connection, ResultSet, and Statement
Class: DriverManager
Exception: SQLException

Documentation:
The java.sql package provides the API for accessing and processing data stored in a data source (usually a relational database) using the Java programming language. This API includes a framework whereby different drivers can be installed dynamically to access different data sources. Although the JDBC API is mainly geared to passing SQL statements to a database, it provides for reading and writing data from any data source with a tabular format.

The java.sql.Connection interface starts a connection (session) with a specific database.

The ResultSet interface generates a table of data representing a database result set, which is usually generated by executing a statement that queries the database.

The Statement interface is an object used for executing a static SQL statement and returning the results it produces.

The DriverManager class is the basic service for managing a set of JDBC drivers.

The SQLException is an exception that provides information on a database access error or other errors.

3. Code lines: In the code lines 53 to 68.
The program runs in embedded mode (default) but also is possible that runs as a client in a server environment depending on the arguments passed to the program in the code lines 53 to 68.

/* the default framework is embedded*/
public String framework = "embedded";
public String driver = "org.apache.derby.jdbc.EmbeddedDriver";
public String protocol = "jdbc:derby:";

You can change the values in this part of the code to run the program as a client in a server environment.

4. Code lines: In the code lines 71 to 203.
The program installs the embedded driver and start up Derby engine.
A DerbyDB database is created because the connection has the value create = true.
The program creates a statement to let commands against the connection.
The program creates a table, add rows, update one and verify the results.
The program releases the result and statement resources.
The program ends the transactions.
The program shuts down Derby, if running in embedded mode.
The program throws an exception, if there is a problem to shut down Derby.

5. Code lines: In the code lines 230 to 249.
There is code when the program runs against Derby running in a client/server framework, using the default port 1527 to start localhost.

2.2 Running the SimpleApp program.

To run the SimpleApp program please read the document localized in: C:\Program Files \IBM\Cloudscape_10.1\demo\programs\simple\ex ample.html of the virtual machine. In this document there are instructions to run the program.


ACTIVITIES OF THE FIFTH WEEK:

  • Try to modify the SimpleApp code to store the DerbyDB database in different directory, to add new sql transactions, etc. Use Eclipse to add or modify code to the SimpleApp program.
  • You can read the JDBC API Documentation of J2SE to learn more about the JDBC packages and classes.
  • You can read the Apache Derby 10.1 API Documentation in the javadoc folder of Cloudscape_10.1. Read the documentation about the packages like authentication, drda, jdbc and tools. Also read the documentation about embedded classes.
  • Try to use Cloudscape Workbench to connect to DerbyDB database, inserting and modifying data, etc.

The four activities include big amount of work, but it would be useful to the developers.
Remember, I am learning too. If you see mistakes, please send me a message in the blog.

Bye for now. We will see the next week!

--------------------------------------------------------------
Monday, March 13, 2006

SIXTH WEEK:

Hello developers of the Cloudscape IBM database!
This week is for running programs in NetworkServer mode (localhost.)

We start here, again.


1. Additional comments about the “Cloudscape server-client” team.
I go to explain how we can change the amount of memory to VMware virtual machines in general and after how we can change the amount of memory to the team.

1.1. Changing the amount of memory to VMware virtual machine.

  1. Select a virtual machine in the Favorites column and we have the first screen of that virtual machine, with different information such as Commands, Devices and Notes areas. In Devices area, you can see the amount of memory of the virtual machine. You can change the amount of memory.
  2. In the Devices area, double click on memory of the virtual machine and we have a new Memory window.
  3. You can select 3-memory option, Guest OS recommended minimum, Recommend memory and Maximum recommended memory. The default value is Recommended memory but you can specify the amount of memory allocated to that virtual machine. It depends of the amount of memory of the host machine. Also you can select intermediate values among the ranks. Please see the note at the end of this activity.
  4. For example, select 96 MB and click on OK button.
  5. Now, you can see in the Devices area, the value of 96 MB of memory to the virtual machine. You can power on and power off the virtual machine but now it is little more slowly.
  6. You can make tests with the minimum, recommended and maximum values of memory of a virtual machine.
  7. We can use these values when there is not enough amount of memory of the host machine.

Note: You need 128 MB or little more to run the host machine and each virtual machine use 128 MB too. You cannot change the memory of the host machine (if you add physical memory, yes) but you can change the memory of the virtual machines.
If you want to run a VMware team and the host machine does not enough memory, VMware sends a message saying that is impossible to run the team. You need to change the memory value of the virtual machines to run the team.
Example: I have 384 MB of memory in my host machine. I want to run a team with 2 virtual machines and each one uses 128 MB of memory. The host machine use a little more of 128 MB and when I power on the team, VMware sends a message saying that there is not enough memory to run the team. You need to change the memory value of the virtual machines in the team (for example 96 MB) to run the team.

1.2. Changing the amount of memory to VMware team.

  1. Click on Cloudscape folder in Favorites column and we have 3 icons, 2 for virtual machines (embedded and localhost) and 1 to team (Cloudscape server-client). The team has 2 virtual machines, server and client.
  2. Select Cloudscape server – client team icon and we have the first screen of the team with 3 areas: Commands, Virtual Machines and LAN Segments, and Notes.
  3. In the Virtual Machines and LAN Segments area we have icons of the 2 virtual machines of the team. Select with double click the first virtual machine icon and we have a Virtual Machine Settings window.
  4. In the right side of the Virtual Machine Settings window change the amount of memory that you decide and click OK button.
  5. Now, select the other virtual machine icon of the team and we have a new Virtual Machine Settings window.
  6. In the right side of the Virtual Machine Settings window change the amount of memory that you decide and click OK button.
  7. At this point, we have changed the amount of memory of each virtual machine of the team if our host machine does not enough memory to run the team. We finish this activity.


2. Understanding and running an application to Cloudscape in NetworkServer mode - localhost with a virtual machine.

We need two elements to make this activity:
1. A computer loaded with J2SE and Cloudscape IBM 10.1.
2. A program developed to Cloudscape NetworkServer mode - localhost.

In the lab, we have a virtual machine setting up especially to NetworkServer mode and it is Windows 2000 with Cloudscape (NetworkServer mode - localhost.)
Also, there is a Network Server sample demo program to NetworkServer mode - localhost in the nserverdemo folder of Cloudscape_10.1 directory, in the VMware virtual machine.

2.1. Understanding the Network Server sample demo program.

The documentation of Cloudscape IBM 10.1 says: The NetworkServer mode is an environment in which multiple applications connect to Derby over the network. These applications run in a client/server environment. Derby runs embedded in a server framework that allows multiple network connections. The framework itself starts an instance of Derby and runs in an embedded environment. However, the client applications do not run in the embedded environment.

In Network Server mode, Cloudscape/Derby processes requests of an application from different Java Virtual Machines and this operation mode is for client/server applications. The previous statement implies that there is a server machine and client’s machines with requests to the server. As a natural consequence we need a network to implement the network server operation mode of Derby/Cloudscape.
But there is an option to run an application to Cloudscape in Network Server mode in one machine with one Java Virtual Machine, using the localhost option.
The Network server sample demo program is a simple JDBC application that interacts with the Derby Network server, in one machine with one Java Virtual Machine, using the localhost option.

I will try to explain the program to myself and I think it would be interesting to other people with interest in the theme.

There are 3 programs that really integrate the Network server sample demo program, each one with specific tasks. The 3 programs are part of the nserverdemo package and each program is a java class (NsSample, NetworkServerUtil and NsSampleClientThread.)

  1. NsSample.java is the entry point to the application. It starts up 2 clients, one with embedded connection and another with client connection. The two clients perform database operations. The program provides 4 constants that can be changed to make tests (NUM_ROWS, ITERATIONS, NUM_CLIENT_THREADS and NETWORKSERVER_PORT.)
  2. NetworkServerUtil.java helps to start and to shutdown the Derby Network server.
  3. NsSampleClientThread.java supports Threads and perform DML operations using JDBC calls.

Remember, if you change the 4 constants or make other changes in the code programs, recompile them again.

The sequence to explain the program is:
First: A statement or code lines or conclusion of the NsSample, NetworkServerUtil and NsSampleClientThread programs.
Then: Official documentation of JDK 5.0 and Cloudscape IBM 10.1.

1. Statement: The Network server sample demo program is a JDBC application.
Please see the answer in the fifth week session (general description of JDBC API.)


2. Conclusion: The programs import different Java interfaces, Java classes, and exceptions of different packages.

Documentation:
A part of them are the same described in the fifth week session. The new packages, interfaces, classes or exceptions are:

The java.io package provides for system input and output through data streams, serialization and the file system. Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.
The java.io.FileOutputStream class is an output stream for writing data to a File or to a FileDescriptor.
The java.io.PritWriter class prints formatted representations of objects to a text-output stream.
The java.io.IOException signals that an I/O exception of some sort has occurred.

The java.net package provides the classes for implementing networking applications and the java.net.InetAddress class represents an Internet Protocol (IP) address. An IP address is either a 32-bit or 128-bit unsigned number used by IP, a lower-level protocol on which protocols like UDP and TCP are built.

The java.lang package provides classes that are fundamental to the design of the Java programming language.
The java.lang.Math class contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.

The java.sql.PreparedStatement interface is an object that represents a precompiled SQL statement.
The java.sql.SQLWarning is an exception that provides information on database access warnings.

The java.util.Random class is used to generate a stream of pseudorandom numbers.

The org.apache.derby.drda package has 2 classes. The NetServelet class can be used to start Derby Network Server from a remote location. The NetworkServerControl class provides the ability to start a Network Server or connect to a running Network Server to shutdown, configure or retrieve diagnostic information.


3. Code lines: The 3 programs have excellent commentary lines and the documentation of them is very good. Please consult the code lines to read the commentaries. They are in:
C:\Program files\IBM\Cloudscape_10.1\demo\programs\nserverde mo of the VMware virtual machine.

The commentary lines are about: when start the Derby Network Server, load of Universal driver and Derby client driver, creation of NsSampledb database, creation of SAMPLETBL table, connection to database, start the client threads, perform DML operations using JDBC calls, open embedded and client connections to perform database operations and shut down the Derby Network server.


2.2 Running the Network Server sample demo program.

To run the Network server sample demo program (3 programs), please read the document localized in:
C:\Program Files \IBM\Cloudscape_10.1\demo\programs\nserverde mo\nserverdemo.html of the VMware virtual machine. In this document there are instructions to run the program.


ACTIVITIES OF THE SIXTH WEEK:

  • Try to modify the NsSample code. The program provides 4 constants that can be changed to make tests (NUM_ROWS, ITERATIONS, NUM_CLIENT_THREADS and NETWORKSERVER_PORT.) Use Eclipse to add or modify code lines.
  • You can read the JDBC API Documentation of J2SE to learn more about JDBC packages and classes.
  • You can read the Apache Derby 10.1 API Documentation in the javadoc folder of Cloudscape_10.1. Read the documentation about the drda and jdbc packages.
  • Try to use Cloudscape Workbench to connect to NsSampledb database, inserting and modifying data, etc.
  • Try to read the Server and administration Guide of Cloudscape IBM 10.1, to learn more about server configurations.

The five activities include big amount of work, but it would be useful to the developers.
Remember, I am learning too. If you see mistakes, please send me a message in the blog.

Bye for now. We will see the next last week!

--------------------------------------------------------------
Wednesday, March 22, 2006

SEVENTH WEEK:

Hello developers of the Cloudscape IBM database!
This is the last week session of the blog.

This last week is for:

1. Explaining some useful options of VMware workstation 5.5.

2. Explaining the different views of a VMware team.

3. Running JDBC applications to Cloudscape 10.1 with Eclipse IDE.

4. Running programs in NetworkServer mode with a VMware team.

5. Conclusions.

COMMENTARY: Before to start the last weekly session of the blog, I want to tell you about an atypical beginning of week. I live in Mexico City and yesterday was a holiday because we celebrate 200 years of Benito Juarez’ birth. Benito Juarez was a Mexican hero when the country had many problems. He was a Zapoteca indigenous who was born in Oaxaca, Mexico. He studied laws and he was attorney, and after he was president of Mexico. We had short vacations from Saturday to Tuesday in Mexico.

Also, the beginning of the week was atypical because each year, when starts the spring there is a ritual in Teotihuacan, near of Mexico City 40 minutes by car. Teotihuacan is a Tolteca archaeological site with 2 large pyramids, the pyramid of the sun and the pyramid of the moon. These pyramids are the highest pyramids of the world and the ritual began to be popular 15 years ago, approximately. Each year, 600 persons were gathered to load positive energy in his or her bodies on the crest of the pyramids. The ritual was consisting of rising the hundreds of steps of the pyramids until arriving to the crest at the noon. Around the ritual there were Aztec dances, tasty food as barbecue and indigenous crafts. Yesterday, there were more than 300,000 persons rising and coming down the pyramids of Teotihuacan and this ceremony has begun to be popular. When the persons are in the crest of the pyramids, they see a spectacular sight of Mexico’s valley, and they see the silhouette of Mexico City too. People are going dressed with white clothes and the objective is to load positive energy and to have good luck in the year. The ceremony is familiar and there are many foreign tourists too. If you want to know the Teotihuacan pyramids, you can see this website:
http://www.mexicocity.com.mx/teoti_i.html


We start here the last week session of the blog.

1. Explaining how we can use Full Screen, Quick Switch, Snapshot and VMware Player options of VMware workstation 5.5.

There are other useful options of VMware workstation 5.5 and they permit working with virtual machines and teams easily.

1.1. Full Screen.
In the principal menu bar, select View > Full Screen (there is a new window) > click on Enter Full Screen button.
This option enlarges the virtual machine display to cover the entire host monitor. The virtual machine no longer appears in a window. This option is available only when a virtual machine or team is power on. The option is comfortable when you work long time with the virtual machine, because you use the whole host machine screen to the virtual machine.
Note: Workstation menus and toolbar are not visible in full screen mode. Press Ctrl-Alt to restore the Workstation window.

1.2. Quick Switch.
In the principal menu bar, select View > Quick Switch.
This option enlarges the Workstation console to cover the entire host monitor. Console tabs are visible, allowing you to switch between your virtual machines and teams with a single click. When you work with teams, this is the best option.
Note: Workstation menus and toolbar are not visible in quick switch mode. Move your cursor to the top of the screen to show the menu and toolbar momentarily. Press View > Quick Switch to restore the Workstation console.

1.3. Snapshot.
In the principal menu bar, select VM > Snapshot (there is a new window) > select Take Snapshot… and there is a new window where you can type the name of snapshot and description > click OK button and there is other window > click OK button.
This option allows you to save the state of a virtual machine in the same manner you might save a word-processing document. You can come back later to that state if you make a mistake with the Revert button. See Using Snapshots for a description of this feature.
You can revert a snapshot in the principal menu bar, select VM > Snapshot (there is a new window) > select Revert to Snapshot and follow the instructions to revert the snapshot.
Also, you can manage the snapshots; select VM > Snapshot > Snapshot Manager and we have a new window with the snapshots of the current virtual machine.
Use the Snapshot Manager to review all snapshots for the current virtual machine and act on them directly.

1.4. VMware Player.
Select start button > Programs > VMware > VMware Player.
It is a free utility that opens and plays VMware Workstation 4.x and 5.x, Microsoft Virtual Server, and Microsoft virtual machines. Read Help topics guide to learn more about VMware Player.



2. Explaining the different views of a VMware team.

We will use parts of this activity when we will run programs in a VMware team.
In the folder Cloudscape, we have a VMware team named Cloudscape server–client.

Select the Cloudscape server–client team in the Favorites column. We have a first view (screen) with 3 different information areas such as Commands, Virtual Machines and LAN Segments, and Notes areas.

2.1 Commands area.

In Commands area you can Start this team or Edit team settings.

a) Click on Start this team option, if you want power on the team.


b) Click on Edit team settings, and you can select 4 tabs such as Connections, Virtual Machines, LAN Segments, and Options.

  • If you select Connections tab, it displays a list of all team virtual machines, their network adapters and each of their network connections. To modify a network connection, highlight the appropriate adapter in this list. Check the box corresponding to the type of connection you want for this NIC. For more information on configuring NICs, see Configuring a Network Adapter (NIC). For information on team LAN segments, see LAN Settings. Note: NICs configured with connections through a DHCP server cannot connect to a team LAN segment.
  • If you select Virtual Machines tab, you can add or remove virtual machines to or from your team as well as set the order in which your team virtual machines start and the number of seconds to wait between starting team virtual machines. The virtual machine startup sequence is top first and bottom last, in the order displayed. To change the startup sequence, select the virtual machine and use the Move Up or Move Down buttons to change its position within the startup sequence. To add a delay time between power on for the selected virtual machine, type the number of seconds you want in the Delay field, and click on OK button.
  • If you select LAN Segments tab, they are virtual networks that are available only to team virtual machines. LAN segments offer increased performance and security. A team LAN segment is fully contained, undetectable and inaccessible from any other network, inside or outside the team. On the LAN Segments tab, you can add, remove and configure team LAN segments. You can set the bandwidth for a LAN segment in two different ways. Use the Bandwidth drop-down menu to set the bandwidth of the LAN segment to match one of several typical network links. Use the Kbps field to specify a numeric throughput upper limit. Changes here are overwritten when you make a selection from the Bandwidth menu. To simulate packet loss over the LAN segment, type the desired percentage of simulated packet loss in the Packet Loss field, and click OK.
  • If you select Options tab, you can change the name of a team. To change the name of a team, type in the new team name under Team name, and click OK.


2.2. Virtual Machines and LAN Segments area.

This area has virtual machine icons that are part of the team, the OS of each virtual machine and the LAN segment of the team with checked boxes to each virtual machine.
Select with double click the first virtual machine icon and we have a new Virtual Machine Settings window for that virtual machine of the team.
In the Virtual Machine setting window , there are 2 tags, Hardware and Options and we can setting up them.

  • If you select Hardware tag, you can setting up devices such as Memory, Hard disk, CD-ROM, Floppy, Ethernet, USB Controller, Audio, and Virtual Processor. Please select each one with one click and select Help tag to see configuring information of that device.
  • If you select Options tag, you can setting up options such as General, Power, Shared Folders, Snapshots, Guest Isolation, and Advanced. Please select each one with one click and select Help tag to see configuring information of that option.

2.3. Notes area.

This area is to document the team and you can type notes for the team.


3. Running JDBC applications to Cloudscape 10.1 with Eclipse IDE.
I need to modify or to add code lines to the Cloudscape demo programs to finish the blog. By the previous reason, I have had to learn Eclipse IDE with the Apache Derby nature to modify or to add code lines. I think that it would be interesting to the developers of the Cloudscape community. I have spent more time but here are 2 examples to Cloudscape 10.1 using Eclipse IDE.


3.1. Running an application in Embedded mode with Eclipse IDE.

Running the SimpleApp program to Cloudscape 10.1 in Embedded mode with the Eclipse IDE.

We need 3 things to run the application:

  1. The Windows 2000 with Cloudscape (embedded mode) virtual machine.
  2. Eclipse with the Derby plug ins installed (derby_core_plugin_10.1.1.zip and derby_ui_plugun_1.1.0.zip.)
  3. An application to embedded mode of Cloudscape (the SimpleApp program.)

1.- Start the VMware workstation 5.5 and click on Cloudscape folder in the Favorites column.
2.- Power on the Windows 2000 with Cloudscape (embedded mode) virtual machine.
3.- Start Eclipse IDE with click on Eclipse icon.
4.- Eclipse asks if you want to use the default workspace that is:
C:\Documents and Settings\administrator\workspace
5.- I want a new workspace named Test_Embedded under administrator folder, because I want to know the new folders and files created there.
6.- With the Eclipse browser I create the new workspace named Test_Embedded in:
C:\Documents and Settings\administrator\Test_Embedded
7.- Select workspace named Test_Embedded in our case and Click on OK button.
8.- At the moment, in Test_Embedded workspace of Eclipse, there is only a folder named .metadata.
9.- Eclipse displays the first screen with the Java perspective. If you see a Welcome screen, please close it.
10.- We go to create a Eclipse project with click on File>New>Project and we have the new project wizard, verify that it is Java Project and click on Next button.
11.- Type the project name (in our case Test_1) with all other default options and click Finish button. Now we have in the Eclipse package explorer the project Test_1.
Note: Here, you can select the version of JDK (1.3, 1.4 or 5.) I selected 5 that is JDK 1.5 or J2SE 5.
12.- Click on Package explorer of Eclipse with the right button of the mouse and we have a new menu window. Select Apache Derby>Add Apache Derby nature.
13.- If you repeat the previous step, you can see 5 options to Apache Derby and Eclipse has the Apache Derby nature.
14.- Now, we go to create a package to the Test_1 project, in the next form.
15.- Select the Eclipse Java Browsing perspective and click File>New>package and starts the Eclipse package wizard. Type the package name ( in our case embedded_demo) and click Finish button.
16.- Now, we go to create a class to the embedded_demo package in the next form.
17.- Select embedded_demo package and click File>New>class and start the Eclipse new java class wizard.
18.- Type the class name (in our case SimpleApp) with all other default options and click Finish button.
19.- Now, we see an editor with the package name (embedded_demo) and the public class name (SimpleApp). The public class is empty and is necessary to add code.
20.- Click on File>Open File… and localize with the browser the SimpleApp.java program in the Cloudscape_10.1 folder of the virtual machine and click Open button.
21.- Now there are 2 tags of the SimpleApp program in the editor window of Eclipse. The first tag has the class empty, and the second tag has the complete code of the SimpleApp program.
22.- Copy and paste the SimpleApp program code of the second tag in the first tag of the Eclipse editor considering the position of the class and the package. Close the second tag.
23.- Select SimpleApp class in Types view of Eclipse and click on Run icon of Eclipse to run the SimpleApp application and we have a new run window.
24.- Select Java Application as configuration and click New button. We have a new window with the project name (Test_1) and the main class (SimpleApp.)
25.- Click on Run button. We have a new Save Resources window with a checkbox selected to the resources to save. Click on OK button.
26.- There is a new Launching windows momentarily but it disappears.
27.- Click on Maximize icon of Console window of Eclipse to see the messages when the program SimpleApp is running.
28.- The application runs OK and we have the next messages in the Console of Eclipse.

SimpleApp starting in embedded mode.
Loaded the appropriate driver.
Connected to and created database derbyDB
Created table derbyDB
Inserted 1956 Webster
Inserted 1910 Union
Updated 1956 Webster to 180 Grand
Updated 180 Grand to 300 Lakeshore
Verified the rows
Dropped table derbyDB
Closed result set and statement
Committed transaction and closed connection
Database shut down normally
SimpleApp finished

29.- Now, we can see in C:\Documents and Settings\administrator\Test_Embedded\Test_1
the derbyDB database (one derbyDB folder and one derby text file.) The derbyDB folder has 2 folders, log and seg0, and the service.properties file.
30.- Now, it is ready to modify code lines or to add more code lines, and to learn more about embedded mode of Cloudscape 10.1.


3.2. Running an application in NetworkServer mode with Eclipse IDE.

Running the Network server sample demo program to Cloudscape 10.1 in NetworkServer mode (localhost), with the Eclipse IDE.
There are 3 programs that really integrate the Network server sample demo program, each one with specific tasks. The 3 programs are part of the nserverdemo package and each program is a java class (NsSample, NetworkServerUtil and NsSampleClientThread.)

We need 3 things to run the application:

  1. The Windows 2000 with Cloudscape (NetworkServer mode – localhost) virtual machine.
  2. Eclipse with the Derby plug ins installed (derby_core_plugin_10.1.1.zip and derby_ui_plugun_1.1.0.zip.)
  3. An application to NetworkServer mode (localhost) of Cloudscape. The Network server sample demo program that are 3 programs. The 3 programs are part of the nserverdemo package and each program is a java class.

1.- Start the VMware workstation 5.5 and click on Cloudscape folder in the Favorites column.
2.- Power on the Windows 2000 with Cloudscape (NetworkServer mode – localhost) virtual machine.
3.- Start Eclipse with click on Eclipse icon.
4.- Eclipse asks if you want to use the default workspace that is:
C:\Documents and Settings\administrator\workspace
5.- I want a new workspace named Test_Localhost under administrator folder, because I want to know the new folders and files created there.
6.- With the Eclipse browser I create the new workspace named Test_Localhost in:
C:\Documents and Settings\administrator\Test_Localhost
7.- Select workspace named Test_Localhost in our case and Click on OK button.
8.- At the moment, in Test_Localhost workspace of Eclipse, there is only a folder named .metadata.
9.- Eclipse displays the first screen with the Java perspective. If you see a Welcome screen, please close it.
10.- We go to create a Eclipse project with click on File>New>Project and we have the new project wizard, verify that it is Java Project and click on Next button.
11.- Type the project name (in our case Test_2) with all other default options and click Finish button. Now we have in the Eclipse package explorer the project Test_2.
Note: Here, you can select the version of JDK (1.3, 1.4 or 5.) I selected 5 that is JDK 1.5 or J2SE 5.
12.- Click on Package explorer of Eclipse with the right button of the mouse and we have a new menu window. Select Apache Derby>Add Apache Derby nature.
13.- If you repeat the previous step, you can see 5 options to Apache Derby and Eclipse has the Apache Derby nature.
14.- Now, we go to create a package to the Test_2 project, in the next form.
15.- Select the Eclipse Java Browsing perspective and click File>New>package and starts the Eclipse package wizard. Type the package name ( in our case nserverdemo) and click Finish button.
16.- Now, we go to create a class to the nserverdemo package in the next form.
17.- Select nserverdemo package and click File>New>class and start the Eclipse new java class wizard.
18.- Type the class name (in our case there are 3 classes and we start with NsSample class) with all other default options and click Finish button. We start with the first program
19.- Now, we see an editor with the package name (nserverdemo) and the public class name (NsSample.) The public class is empty and is necessary to add code.
20.- Click on File>Open File… and localize with the browser the NsSample.java program in the Cloudscape_10.1 folder of the virtual machine and click Open button.
21.- Now there are 2 tags of NsSample program in the editor window of Eclipse. The first tag has the class empty, and the second tag has the complete code of the NsSample program.
22.- Copy and paste the NsSample program code of the second tag in the first tag of the Eclipse editor considering the position of the class and the package. Close the second tag.
23.- Repeat the steps 16 to 22, but now to the other 2 classes, NetworkServerUtil and NsSampleClientThread.
24.- Now, we have 3 classes, NsSample, NetworkServerUtil and NsSampleClientThread in the package nserverdemo.
25.- Select NsSample class in Types view of Eclipse and click on Run icon of Eclipse to run the NsSample class that is the entry point to the application and we have a new run window.
26.- Select Java Application as configuration and click New button. We have a new window with the project name (Test_2) and the main class (NsSample.)
27.- Click on Run button. We have a new Save Resources window with a checkbox selected to the resources to save. Click on OK button.
28.- There is a new Launching windows momentarily but it disappear.
29.- Click on Maximize icon of Console window of Eclipse to see the messages when the program NsSample is running.
30.- The application runs OK and we have the next messages in the Console of Eclipse.

Using JDBC driver: org.apache.derby.jdbc.ClientDriver
Derby Network Server created
El servidor está listo para aceptar conexiones en el puerto 1621.
Número de conexión: 1.
[NsSample] Derby Network Server started.
[NsSample] Sample Derby Network Server program demo starting.
Please wait .....................
Número de conexión: 2.
[NsSampleWork] Begin creating table - SAMPLETBL and necessary indexes.
[NsSampleClientThread] Thread id - 1; started.
[NsSampleWork] Thread id - 1; requests database connection, dbUrl =jdbc:derby:NSSampledb;
[NsSampleClientThread] Thread id - 2; started.
[NsSampleWork] Thread id - 2; requests database connection, dbUrl =jdbc:derby://localhost:1621/NSSampledb;create=true;
Número de conexión: 3.
[NsSampleWork] Thread id - 1; deleted 1 row with t_key = 9822
[NsSampleWork] Thread id - 1 selected 1 row [691,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 2; deleted 0 row with t_key = 9822
[NsSampleWork] Thread id - 2; inserted 1 row.
[NsSampleWork] Thread id - 1 selected 1 row [691,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 1 selected 1 row [691,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 2; updated 1 row with t_key = 9712
[NsSampleWork] Thread id - 1; inserted 1 row.
[NsSampleWork] Thread id - 2 selected 1 row [53,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 1 selected 1 row [53,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 1 selected 1 row [53,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 2; updated 1 row with t_key = 9712
[NsSampleWork] Thread id - 1; inserted 1 row.
[NsSampleWork] Thread id - 1 selected 1 row [55,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 2; inserted 1 row.
[NsSampleWork] Thread id - 2; updated 1 row with t_key = 9712
[NsSampleWork] Thread id - 1 selected 1 row [57,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 1; closed connection to the database.
[NsSampleWork] Thread id - 2 selected 1 row [57,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 2 selected 1 row [57,Derby22 ,9.4391644E9,9712]
[NsSampleWork] Thread id - 2; deleted 1 row with t_key = 9712
[NsSampleWork] Thread id - 2; closed connection to the database.
[NsSampleClientThread] Thread id - 2; finished all tasks.
[NsSampleClientThread] Thread id - 1; finished all tasks.
[NsSample] Shutting down network server.
Número de conexión: 4.
Conclusión satisfactoria.
[NsSample] End of Network server demo.


31.- Now, we can see in C:\Documents and Settings\administrator\Test_Localhost\Test_2
the NSSampledb database (one NSSampledb folder and one derby text file.) The NSSampledb folder has the 3 folders log, seg0 and tmp, and 2 files, the db.lck file and the service.properties file.
32.- Now it is ready to modify code lines or to add more code lines, and to learn more about NetworkServer mode of Cloudscape 10.1.


4. Running programs in NetworkServer mode with a VMware team.

The Cloudscape 10.1 information says that, if the network server is not on the computer that you are working on, you must use the -h option to specify the host name, ip address, or a value of 0.0.0.0 to listen on all interfaces. You should run under the Java security manager and enable user authentication before using this option.
My objective is to verify how works Cloudscape 10.1 in NetworkServer mode with different Java Virtual Machines. By this reason, we will not use user authentication, but this theme is extremely important by security. I am reading the article “Apache Derby security by Jean T. Anderson, Cloudscape community Architect”. The article has excellent examples and demos about this important topic.

To finish the blog, I need the do the next:
First, checking that the Cloudscape client-server team, is a LAN segment (theme 4.1.)
Second, I have tested the NetworkServer mode of Cloudscape with different Java Virtual Machines, running processes in NetworkServer mode with Cloudscape 10.1 tools and scripts (theme 4.2.)
Third, running the SimpleNetworkServerSample and SimpleNetworkClientSample programs in one virtual machine (theme 4.3.)
Fourth, running programs in NetworkServer mode with a VMware team (theme 4.4.)
Finally, I will present the conclusions (theme 5.)


4.1. Checking that the Cloudscape client-server team, is a LAN segment.

I need to check that the team named Cloudscape server-client is working like a LAN with 2 virtual machines.

a) Click on VMware workstation 5.5 icon to start it.
b) Click on Cloudscape folder in Favorites column and we have 3 icons, please select the Cloudscape server-client team (the team has 2 virtual machines, server and client.) We have the first screen of the team.
c) In the Commands area, power on the team with one click on start this team.
d) We have other screen of the team with 2 areas. The smaller area is on the top and it is a horizontal section with little screens of the virtual machines that are part of the team. In our case, we have 2 virtual machines in the team. Here you can select with one click each one of the virtual machines to work on it. The biggest area is to a virtual machine of the team who is selected on the top and you can work on it.
e) Each virtual machine of the team, turns on and starts the guest operating system in each one (in may case Windows 2000 but it can be other.) You need to type the password that you have assigned to each one, to work with the team. The process takes between 5 and 10 minutes depending of the microprocessor speed and amount of memory of your host machine.
f) Now, we go to verify that the team is a LAN segment.
g) In the smaller area of the screen, select with one click the Windows 2000 with Cloudscape (NetworkServer mode – server) virtual machine.
h) In the biggest area of the screen, now we can work with the server virtual machine to verify the LAN segment. You can use the Full Screen or Quick Switch options to work friendlier. These options were explained at the beginning of this last week session.
i) In the desktop of the server virtual machine, click on My network sites icon of Windows 2000 desktop, and we have a new window.
j) Click on The whole network icon, and we have a new window.
k) Click on complete content link, and we have a new window with two icons.
l) Click on Microsoft Windows Network icon, and we have a new window.
m) Click on Manufacture icon, and we have a new window.
n) We have PC3 and PC4 icons and it fact verifies that they are the equipments of our LAN segment. Note: PC3 is the server virtual machine and PC4 is the client virtual machine.
o) Please, repeat the previous 9 steps to the client virtual machine (PC4) to verify that the client virtual machine is part of the Manufacture workgroup in our LAN segment.
p) Finally, we have verified that PC3 (server virtual machine) and PC4 (client virtual machine) are part of the Manufacture workgroup in our LAN segment. It is important, because if we do not have a LAN, we cannot do the next two activities.


4.2. Running processes in NetworkServer mode with a VMware team and Cloudscape 10.1 tools and scripts.

I need to verify how works Cloudscape 10.1 in NetworkServer mode with different Java Virtual Machines. By the previous reasons, I go to use the ij and sysinfo tools, and the scripts of Cloudscape 10.1 to verify Cloudscape NetworkServer mode, starting the Derby Network Server and using IP addresses or host names (I will use host names.)

4.2.1. Starting the Derby Network Server in the server virtual machine (PC3) of the team with the startNetworkServer script.

We need 2 things to start this activity:

  • Power on the team Cloudscape server-client and turn on both, the server virtual machine (PC3) and the client virtual machine (PC4.) Please select the server virtual machine (PC3) to work on it.
  • In the server virtual machine (PC3) we have the files deby.jar and derbynet.jar in the classpath. Please, add derbytools.jar in the classpath because we need to use the sysinfo tool and the scripts of Cloudscape 10.1.

1.- Open a MS-DOS windows in the server virtual machine.
2.- Type the next to start the Derby Network Server in the PC3 machine and listening in the port 1368:
C:\>java org.apache.derby.drda.NetworkServerControl start -h PC3 -p 1368
The command generates the next answer:
The server is ready to accept connections in port 1368.
In this window you cannot write more commands because the Derby Network Server is running.
3.- Open other MS-DOS Window in the server virtual machine and type the next to know information to Java environment and Derby Network Server.
C:\>java org.apache.derby.drda.NetworkServerControl sysinfo -h PC3 -p 1368

This is the screen when I typed the previous command in my computer:
C:\>java org.apache.derby.drda.NetworkServerControl sysinfo -h PC3 -p 1368
--------- Informaci¾n de Derby Network Server --------
Versi¾n: CSS10011/10.1.2.1 Build: 330608 ID del producto DRDA: CSS10011
-- listing properties --
derby.drda.maxThreads=0
derby.drda.keepAlive=true
derby.drda.minThreads=0
derby.drda.portNumber=1368
derby.drda.logConnections=false
derby.drda.timeSlice=0
derby.drda.startNetworkServer=false
derby.drda.host=PC3
derby.drda.traceAll=false
------------------ Java Information ------------------
Java Version: 1.5.0_05
Java Vendor: Sun Microsystems Inc.
Java home: C:\Archivos de programa\Java\jre1.5.0_05
Java classpath: .;C:\Archivos de programa\Java\jdk1.5.0_05\lib\tools.jar;C:\Arc
hivos de programa\Java\jdk1.5.0_05\lib\dt.jar;C:\Archivos de programa\IBM\Clouds
cape_10.1\lib\derby.jar;C:\Archivos de programa\IBM\Cloudscape_10.1\lib\derbynet
.jar;C:\Archivos de programa\IBM\Cloudscape_10.1\lib\derbytools.jar
OS name: Windows 2000
OS architecture: x86
OS version: 5.0
Java user name: Administrador
Java user home: C:\Documents and Settings\Administrador
Java user dir: C:java.specification.name: Java Platform API Specification
java.specification.version: 1.5
--------- Derby Information --------
JRE - JDBC: J2SE 5.0 - JDBC 3.0
[C:\Archivos de programa\IBM\Cloudscape_10.1\lib\derby.jar] 10.1.2.1 - (330608)
[C:\Archivos de programa\IBM\Cloudscape_10.1\lib\derbynet.jar] 10.1.2.1 - (33060
8)
[C:\Archivos de programa\IBM\Cloudscape_10.1\lib\derbytools.jar] 10.1.2.1 - (330
608)
------------------------------------------------------
----------------- Locale Information -----------------
------------------------------------------------------
C:\>

4.- Remember, the previous 3 steps are realized in the server virtual machine. Now, we have the Derby Network Server running in PC3 host and listening in port 1368 of a LAN segment. The Derby Network Server is ready to attend requests of the clients of other Java virtual machines. Note: When you finish this activity, please go to the sub theme 4.2.2 and ends it, because you need running the Derby Network Server. When you finish the sub theme 4.2.2, returns to the next 5 step because you need to shut down the Derby Network Server
5.- When you close the client connections, you must shut down the Derby Network Server with the next command:
C:\>java org.apache.derby.drda.NetworkServerControl shutdown -h PC3 -p 1368
Conclusi¾n satisfactoria.
C:\>
Note: This step is the last step when you end the transactions of the clients. It is important because if you do not shut down the Derby Network Server, the port can be blockaded in the server virtual machine.


4.2.2. Making client transactions with the ij tool in the client virtual machine (PC4) of the team.

We need 2 things to start this activity:

  • Select the client virtual machine (PC4) of the team, to work on it.
  • Verify that the client virtual machine (PC4) has the files derbytools.jar, derbyclient.jar, db2jcc.jar, and db2jcc_license_c.jar in the classpath. We need to use the ij tool of Cloudscape 10.1.

1.- Open a MS-DOS windows in the client virtual machine and type the next to start the ij tool:
C:\>java org.apache.derby.tools.ij
The command generates the next answer:
ij version 10.1
ij>
2.- I have typed commands to load the client driver, connect and create 2 databases. The mybase1 database is in root C:\ of the server virtual machine and the mybase2 database is in the folder C:\ DBases_sercli\ of the server virtual machine. Each database has a table (menu1 and manu2) that were created with ij commands (CREATE TABLE and INSERT INTO.) I used the SELECT command to verify the 2 tables were created. I closed the connections in the client virtual machine and after I shut down the Derby network Server in the server virtual machine.

This activity was in the client virtual machine and this is the screen whit the ij commands that I typed in my computer:

C:\>java org.apache.derby.tools.ij
ij version 10.1
ij> driver 'org.apache.derby.jdbc.ClientDriver';
ij> show connections;
No connections available.
ij> connect 'jdbc:derby://PC3:1368/mybase1;create=true';
ij> show connections;
CONNECTION0* - jdbc:derby://PC3:1368/mybase1;create=true
* = current connection
ij> connect 'jdbc:derby://PC3:1368/C:\DBases_sercli\mybase2;create=true';
ij(CONNECTION1)> show connections;
CONNECTION0 - jdbc:derby://PC3:1368/mybase1;create=true
CONNECTION1* - jdbc:derby://PC3:1368/C:\DBases_sercli\mybase2;create=true
* = current connection
ij(CONNECTION1)> set connection connection0;
ij(CONNECTION0)> autocommit off;
ij(CONNECTION0)> CREATE TABLE menu1 (course CHAR(10), item CHAR(20), price INT);

0 rows inserted/updated/deleted
ij(CONNECTION0)> INSERT INTO menu1 VALUES ('entree', 'lamb chop', 14),
('dessert', 'creme brulee', 6),
('appetizer', 'baby greens', 7);
3 rows inserted/updated/deleted
ij(CONNECTION0)> SELECT * FROM menu1;
COURSE ITEM PRICE
-------------------------------------------
entree lamb chop 14
dessert creme brulee 6
appetizer baby greens 7

3 rows selected
ij(CONNECTION0)> commit;
ij(CONNECTION0)> autocommit on;
ij(CONNECTION0)> set connection connection1;
ij(CONNECTION1)> autocommit off;
ij(CONNECTION1)> CREATE TABLE menu2 (course CHAR(10), item CHAR(20), price INT);

0 rows inserted/updated/deleted
ij(CONNECTION1)> INSERT INTO menu2 VALUES ('entree', 'lamb chop', 14),
('dessert', 'creme brulee', 6),
('appetizer', 'baby greens', 7);
3 rows inserted/updated/deleted
ij(CONNECTION1)> SELECT * FROM menu2;
COURSE ITEM PRICE
-------------------------------------------
entree lamb chop 14
dessert creme brulee 6
appetizer baby greens 7

3 rows selected
ij(CONNECTION1)> commit;
ij(CONNECTION1)> autocommit on;
ij(CONNECTION1)> show connections;
CONNECTION0 - jdbc:derby://PC3:1368/mybase1;create=true
CONNECTION1* - jdbc:derby://PC3:1368/C:\DBases_sercli\mybase2;create=true
* = current connection
ij(CONNECTION1)> disconnect all;
ij> show connections;
No connections available.
ij> exit;
C:\>

3.- Remember, the 2 previous steps are realized in the client virtual machine of the team but these transactions have affected the server virtual machine of the team and now, we have 2 new databases (mybase1 and mybase2) in the server machine where is installed the Derby Network server.
Also, we have verified that the Derby Network Server is running in PC3 host and it is listening in port 1368 to attend request of the clients of other Java virtual machines of a LAN segment.
4.- Now you need to shut down the Derby Network Server in the server virtual machine. Please, return to the step 5 of the 4.2.1 sub theme and read the instruction to shut down the Derby Network Server.


4.3. Running the SimpleNetworkServerSample and SimpleNetworkClientSample programs in one virtual machine.

We need 2 things to start this activity:

  • One machine (can be any of our 4 virtual machine.) Power on the virtual machine.
  • The SimpleNetworkServerSample and SimpleNetworkClientSample programs, and the document simpleserversample.html that explains clearly how to run the 2 programs in one machine to localhost listening in port 1527. The programs and the document are in C:\Program files\IBM\Cloudscape_10.1\demo\programs.

I ran the 2 programs and I had the next results:

First Window:
The first MS-DOS window is to run the SimpleNetworkServerSample program. Here the Derby Network Server is ready to attend client requests in localhost with port 1527.
This is the screen that I typed in my computer.
C:\Archivos de programa\IBM\Cloudscape_10.1\demo\programs\nserverdemo>java Simpl
eNetworkServerSample
Starting Network Server
Testing if Network Server is up and running!
Derby Network Server now running
Got an embedded connection.
Testing embedded connection by executing a sample query
number of rows in sys.systables = 16
While my app is busy with embedded work, ij might connect like this:
$ java -Dij.user=me -Dij.password=pw -Dij.protocol=jdbc:derby://localhos
t:1527/ org.apache.derby.tools.ij
ij> connect 'NSSimpleDB';
Clients can continue to connect:
Press [Enter] to stop Server

Second window:
The second MS-DOS window is to run the SimpleNetworkClientSample program. Here the clients request attention to make transactions with the Derby Network Server in localhost with port 1527. Here is the screen.

C:\Archivos de programa\IBM\Cloudscape_10.1\demo\programs\nserverdemo>java Simpl
eNetworkClientSample derbyClient
Starting Sample client program
Got a client connection via the DriverManager.
connection from datasource; getDriverName = Apache Derby Network Client JDBC Dri
ver
Got a client connection via a DataSource.
Testing the connection obtained via DriverManager by executing a sample query
number of rows in sys.systables = 16
Testing the connection obtained via a DataSource by executing a sample query
number of rows in sys.systables = 16
Goodbye!
C:\Archivos de programa\IBM\Cloudscape_10.1\demo\programs\nserverdemo>start ij
C:\Archivos de programa\IBM\Cloudscape_10.1\demo\programs\nserverdemo>

Considering that the Derby Network Server is running yet, I opened other window to start ij tool because I want to connect with the NSSimpleDB database created when we ran the SimpleNetworkServerSample program. Here is the screen.

ij version 10.1
ij> show connections;
No connections available.
ij> connect 'jdbc:derby://localhost:1527/NSSimpleDB';
ij> show connections;
CONNECTION0* - jdbc:derby://localhost:1527/NSSimpleDB
* = current connection
ij> SELECT * FROM sys.systables;
TABLEID TABLENAME

&SCHEMAID &
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
80000010-00d0-fd77-3ed8-000a0a0b1900SYSCONGLOMERATES

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
80000018-00d0-fd77-3ed8-000a0a0b1900SYSTABLES

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
8000001e-00d0-fd77-3ed8-000a0a0b1900SYSCOLUMNS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
80000022-00d0-fd77-3ed8-000a0a0b1900SYSSCHEMAS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
8000002f-00d0-fd77-3ed8-000a0a0b1900SYSCONSTRAINTS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
80000039-00d0-fd77-3ed8-000a0a0b1900SYSKEYS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
8000003e-00d0-fd77-3ed8-000a0a0b1900SYSDEPENDS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
c013800d-00d7-ddbd-08ce-000a0a411400SYSALIASES

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
8000004d-00d0-fd77-3ed8-000a0a0b1900SYSVIEWS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
80000056-00d0-fd77-3ed8-000a0a0b1900SYSCHECKS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
8000005b-00d0-fd77-3ed8-000a0a0b1900SYSFOREIGNKEYS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
80000000-00d1-15f7-ab70-000a0a0b1500SYSSTATEMENTS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
80000000-00d3-e222-873f-000a0a0b1900SYSFILES

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
c013800d-00d7-c025-4809-000a0a411200SYSTRIGGERS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
f81e0010-00e3-6612-5a96-009e3a3b5e00SYSSTATISTICS

S8000000d-00d0-fd77-3ed8-000a0a0b1900R
c013800d-00f8-5b70-bea3-00000019ed88SYSDUMMY1

Sc013800d-00f8-5b53-28a9-00000019ed88R

16 rows selected
ij> disconnect all;
ij> connect 'jdbc:derby://localhost:1527/NSSimpleDB';
ERROR (no SQLState): java.security.PrivilegedActionException : Error opening soc
ket to server localhost on port 1527 with message : null
ij>

Here, I had an error but it was because when I disconnected all connections, I went to the first window and I shut down the Derby network server with click on Enter key. After, I returned to the second window and I wanted to connect with the NSSimpleDB database but the error opening socket to server was because the Derby Network Server was shut down.


4.4. Running programs in NetworkServer mode with a VMware team.

We have a VMware team named Cloudscape server-client working like a LAN with 2 virtual machines, the server virtual machine (PC3) and the client virtual machine (PC4.)
Each virtual machine of the team has installed and configured Cloudscape 10.1 and Eclipse IDE with Derby nature.

To run the programs SimpleNetworkServerSample and SimpleNetworkClientSample with our VMware team (Cloudscape server-client), we need to modify some code lines of the programs because they are designed to run with localhost and port 1527. Please, modify the programs with Eclipse IDE.

The SimpleNetworkServerSample program is designed to run the Derby Network Server in the host name=localhost and port number=1527. You must modify some code lines because we want that the Derby Network Server starts with host name=PC3 and port number=1368.
Note: The host name is PC3 because it is the name of the server virtual machine in the LAN of our VMware team (Cloudscape server-client). The port name can be any, but it must be the same in the server virtual machine application and the client virtual machines application. Also, the SimpleNetworkServerSample program runs in the server virtual machine (PC3) of our VMware team.

The SimpleNetworkClientSample program is designed to run clients requesting attention to make transactions with the Derby Network Server in host name=localhost and port number=1527. You must modify some code lines, because we want that the clients requesting attention to make transactions, with the Derby Network Server in host name=PC3 and port number=1368.
Note: The host name is PC3 and the port number is 1368 because the clients must connect with the Derby Network Server and it is running in PC3 with port 1368. Also, the SimpleNetworClientSample program runs in the client virtual machine (PC4) of our VMware team.


5. Conclusions.

The objective of the “Laboratory of database with Cloudscape IBM 10.1 and VMware workstation 5.5” was to learn a Java embedded database.
I started as beginner in Java and Cloudscape IBM 10.1, 4 months ago but now I understand important themes such as the 2 operation modes of Cloudscape (embedded and NetworkServer), the Derby drivers, the function of the Derby Network Server, the function of the client applications, the programming with Java, JDBC and SQL.

I believe that the support of VMware workstation 5.5 was very important in 3 principal aspects such as learning, testing and saving money.
Learning because I feel that the learning process of Cloudscape was short, comparing it with the learning process of Cloudscape without use VMware workstation 5.5. I have saved time.
Testing because it gave me the possibility to create virtual machines to test some of the most important aspects of Cloudscape 10.1, quickly and without affect my host machine.
Saving money because if I want to learn and to test Cloudscape with physical infrastructure I would need 4 physical PCs with LAN infrastructure. Comparing the cost in money of the previous physical infrastructure with one physical PC with VMware workstation 5.5 to create complete virtual machines, I have saved money.

I think that the objective of learning Cloudscape was reached because now I understand the philosophy of Cloudscape and I understand the JDBC applications included with Cloudscape IBM, too. In the way, I had to learn or had to go deeply into other topics such as Eclipse 3.1, Cloudscape Workbench 1.0, web page design, creation of a blog, and writing in English language because my mother language is Spanish.
I am learning more about Apache Derby security. The themes about authentication, authorization, encryption and Java 2 Security Manager are very interesting. Also I need to learn more about procedures, triggers and exceptions.
My personal challenge is to reach an intermediate level developing JDBC applications to Cloudscape 10.1 in the next 3 months.

I want to thank to IBM the opportunity to participate in the IBM developersWorks Peer Advisors Network in the Cloudscape Project. The experience has been amusing and I wish that the blog had been useful to the developers and users of the IBM Cloudscape community forum.
I will follow reading the questions of the users and developers in the IBM Cloudscape forum and I will ask other questions sometimes.

Note: Also, I want to thank to Google the housing of this blog. Sometimes, I see other blogs in blogger.com and they are interesting too.


Good luck and have a good day.

Regards!


Cruz Castillo.




4 Comments:

  • I've been enjoying your blog entries and wanted to provide a little additional information that might clarify a couple points.

    Derby works with any certified J2SE of 1.3 or higher, so it will run on any machine that can run that version or higher and it works with more than just the Sun and IBM J2SE's -- any certified J2SE should work.

    Also, for that client/server mode, Derby 10.1 includes both the Derby Network Server and the Derby Network Client -- no additional software is required. If you want to use the Derby Network Client JDBC driver, use the derbyclient.jar file that comes with Derby (and IBM Cloudscape).

    IBM also provides the DB2 Universal JDBC driver that works with Derby -- that's the db2jcc.jar/db2jcc_license_c.jar files that the blog mentions. It is currently included with IBM Cloudscape 10.1 and can also be downloaded from developerWorks.

    At any rate, you only need the jars for the specific JDBC driver you're using.

    By Anonymous Jean T. Anderson, at 12:54 PM  

  • Hello readers of the blog.

    I want to thank the message of Jean T. Anderson with observations about the blog. I have added additional information to clarify a couple of points that Jean T. Anderson says in her message. Thanks for the message again.

    The first message motivated me to make a complete review of the blog. I am making the same activities that I mention in the blog, half-a-week to 1 week forward in time when I post the blog. I try to explain the activities with truthfulness and logicalness but always is possible to have a better technological blog.

    I have revised the whole blog to correct errors. The structure of the blog is the same and I only have added text about clarify a couple of points that Jean T. Anderson mentions in her message. Also, I have corrected the blog about planning errors and grammar errors.

    Even so, if you observe additional mistakes, please send me a message, they are welcome.

    Regards!

    By Blogger Cruz Castillo, at 9:11 PM  

  • Very nice! I found a place where you can
    make some nice extra cash secret shopping. Just go to the site below
    and put in your zip to see what's available in your area.
    I made over $900 last month having fun!
    make extra money

    By Anonymous Anonymous, at 5:18 AM  

  • Very nice! I found a place where you can
    make some nice extra cash secret shopping. Just go to the site below
    and put in your zip to see what's available in your area.
    I made over $900 last month having fun!

    make extra money

    By Anonymous Anonymous, at 11:02 AM  

Post a Comment

<< Home