![]() Documentation Top ![]() Global Index ![]() Top of Demos ![]() |
Simple JDBC ApplicationThis example program is a very minimal JDBC application. JDBC is the primary API for interacting with Cloudscape. This program accomplishes the following tasks:
The application can run in any of the following environments:
This example shows that the application works almost the same regardless of the environment. Only minor modifications to the code are needed to suit the environment.
|
You run the utility like this:
java COM.cloudscape.tools.sysinfo -cp arguments
So for the arguments you need here, run it like this (all on one line):
java COM.cloudscape.tools.sysinfo -cp embedded
CloudscapeSimpleApp.class
If your environment is set up correctly, the utility shows output indicating success. It looks like this:
FOUND IN CLASS PATH:
Cloudscape primary library (cloudscape.jar or cloudsync.jar)
Cloudscape license (for evaluation customers, this is in license.jar; for other customers, this is in the main cloudscape library)
user-specified class (CloudscapeSimpleApp)
SUCCESS: All Cloudscape-Related classes for embedded environment found in class path.
If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the directory containing the CloudscapeSimpleApp class to your class path, the utility would indicate as such:
Testing for presence of Cloudscape-related libraries for embedded environment.
FOUND IN CLASS PATH:
Cloudscape primary library (cloudscape.jar or cloudsync.jar)
Cloudscape license (for evaluation customers, this is in license.jar; for other customers, this is in the main cloudscape library)
NOT FOUND IN CLASS PATH:
user-specified class (CloudscapeSimfleApp)
(CloudscapeSimpleApp not found.)
A successful run produces the following output:
CloudscapeSimpleApp starting in embedded mode.
Loaded the appropriate driver.
Connected to and created database CloudscapeDB
Created table CloudscapeDB
Inserted 1956 Webster
Inserted 1910 Union
Updated 1956 Webster to 180 Grand
Updated 180 Grand to 300 Lakeshore
Verified the rows
Dropped table CloudscapeDB
Closed result set and statement
Committed transaction and closed connection
Database shut down normally
CloudscapeSimpleApp finished
In this demo, you start Cloudconnector, then connect to it from a client. You will be creating two different environmentsone for the server and one for the client.
You must have both weblogic.properties and a folder called CloudscapeServer in the directory in order to start Cloudconnector. If either of these is missing, Cloudconnector does not start.
(The directory in which these items live is also known as weblogic.system.home.)
You run the utility like this:
java COM.cloudscape.tools.sysinfo -cp arguments
So for the arguments you need here, run it like this (all on one line):
java COM.cloudscape.tools.sysinfo -cp CloudconnectorServer
If your environment is set up correctly, the utility shows output indicating success. It looks like this:
FOUND IN CLASS PATH:
Cloudscape primary library (cloudscape.jar or cloudsync.jar)
Cloudscape license (for evaluation customers, this is in license.jar; for other customers, this is in the main cloudscape library)
Main Cloudconnector libraries (/classes)
Cloudconnector auxiliary libraries (weblogicaux.jar)
Cloudconnector license library (/license)
SUCCESS: All Cloudscape-Related classes for CloudconnectorServer environment found in class path.
If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the %CLOUDSCAPE_INSTALL%/frameworks/cloudconnect/license/ directory, the utility would indicate as such:
Testing for presence of Cloudscape-related libraries for CloudconnectorServer environment.
FOUND IN CLASS PATH:
Cloudscape primary library (cloudscape.jar or cloudsync.jar)
Cloudscape license (for evaluation customers, this is in license.jar; for other customers, this is in the main cloudscape library)
Main Cloudconnector libraries (/classes)
Cloudconnector auxiliary libraries (weblogicaux.jar)
NOT FOUND IN CLASS PATH:
Cloudconnector license library (/license)
(/WebLogicLicense.xml not found.)
You run the utility like this:
java COM.cloudscape.tools.sysinfo -cp arguments
So for the arguments you need here, run it like this (all on one line):
java COM.cloudscape.tools.sysinfo -cp CloudconnectorClient
CloudscapeSimpleApp.class
If your environment is set up correctly, the utility shows output indicating success. It looks like this:
Testing for presence of Cloudscape-related libraries for CloudconnectorClient environment.
FOUND IN CLASS PATH:
Cloudscape Client libraries (client.jar)
Main Cloudconnector libraries (/classes)
Cloudconnector auxiliary libraries (weblogicaux.jar)
Cloudconnector license library (/license)
user-specified class (CloudscapeSimpleApp)
SUCCESS: All Cloudscape-Related classes for CloudconnectorClient environment found in class path.
If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the %CLOUDSCAPE_INSTALL%/frameworks/cloudconnect/license/ directory, the utility would indicate as such:
Testing for presence of Cloudscape-related libraries for CloudconnectorClient environment.
FOUND IN CLASS PATH:
Cloudscape Client libraries (client.jar)
Main Cloudconnector libraries (/classes)
Cloudconnector auxiliary libraries (weblogicaux.jar)
Cloudconnector license library (/license)
user-specified class (CloudscapeSimpleApp)
SUCCESS: All Cloudscape-Related classes for CloudconnectorClient environment found in class path.
Users on other platforms can execute the command that the file contains instead.
After starting the server, you should see startup messages from the server. If the server starts successfully, the last message will say:ListenThread> Listening on port 7001
java CloudscapeSimpleApp sysconnectclient
The argument sysconnectclient indicates that the application should use the Cloudconnector framework. The application also assumes that the server framework is running on localhost at the default port number. Examine the source code for the application to see how it works.
A successful run produces the following output:
CloudscapeSimpleApp starting in sysconnect mode.
Loaded the appropriate driver.
Connected to and created database CloudscapeDB
Created table CloudscapeDB
Inserted 1956 Webster
Inserted 1910 Union
Updated 1956 Webster to 180 Grand
Updated 180 Grand to 300 Lakeshore
Verified the rows
Dropped table CloudscapeDB
Closed result set and statement
Committed transaction and closed connection
CloudscapeSimpleApp finished
Users on other platforms can execute the Java command that the script contains, instead:
java weblogic.T3Admin t3://localhost:7001 SHUTDOWN system
paceesalute
Stopping the server by typing ^C in the server console window means that Cloudscape will have to run recovery on the database the next time it starts up. Avoid this by using the stopCS command to stop the server framework.
In this demo, you will start the RmiJdbc Server, then connect to it from a client. You will be creating two different environmentsone for the server and one for the client.
You run the utility like this:
java COM.cloudscape.tools.sysinfo -cp arguments
So for the arguments you need here, run it like this (all on one line):
java COM.cloudscape.tools.sysinfo -cp RmiServer
If your environment is set up correctly, the utility shows output indicating success. It looks like this:
FOUND IN CLASS PATH:
Cloudscape primary library (cloudscape.jar or cloudsync.jar)
Cloudscape license (for evaluation customers, this is in license.jar; for other customers, this is in the main cloudscape library)
RmiJdbc server and client libraries (RmiJdbc.jar)
SUCCESS: All Cloudscape-Related classes for RmiServer environment found in class path.
If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the %CLOUDSCAPE_INSTALL%/frameworks/RmiJdbc/classes/RmiJdbc.jar file, the utility would indicate as such:
Testing for presence of Cloudscape-related libraries for RmiServer environment.
FOUND IN CLASS PATH:
Cloudscape primary library (cloudscape.jar or cloudsync.jar)
Cloudscape license (for evaluation customers, this is in license.jar; for other customers, this is in the main cloudscape library)
NOT FOUND IN CLASS PATH:
RmiJdbc server and client libraries (RmiJdbc.jar)
(RmiJdbc.RJConnection not found.)
You run the utility like this:
java COM.cloudscape.tools.sysinfo -cp arguments
So for the arguments you need here, run it like this (all on one line):
java COM.cloudscape.tools.sysinfo -cp RmiClient
CloudscapeSimpleApp.class
If your environment is set up correctly, the utility shows output indicating success. It looks like this:
Testing for presence of Cloudscape-related libraries for RmiClient environment.
FOUND IN CLASS PATH:
Cloudscape Client libraries (client.jar)
RmiJdbc server and client libraries (RmiJdbc.jar)
user-specified class (CloudscapeSimpleApp)
SUCCESS: All Cloudscape-Related classes for RmiClient environment found in class path.
If something is missing from your class path environment, the utility indicates what is missing. For example, if you neglected to add the %CLOUDSCAPE_INSTALL%/frameworks/RmiJdbc/classes/RmiJdbc.jar file, the utility would indicate as such:
Testing for presence of Cloudscape-related libraries for RmiClient environment.
FOUND IN CLASS PATH:
Cloudscape Client libraries (client.jar)
user-specified class (CloudscapeSimpleApp)
NOT FOUND IN CLASS PATH:
RmiJdbc server and client libraries (RmiJdbc.jar)
(RmiJdbc.RJConnection not found.)
Users on other platforms can execute the command that the file contains instead (all on one line):
java -ms16m -mx32m RmiJdbc.RJJdbcServer
COM.cloudscape.core.JDBCDriver
After starting the server, you should see startup messages from Cloudscape. If the server starts successfully, the last two messages will say:
COM.cloudscape.core.JDBCDriver registered in DriverManager /RmiJdbcServer bound in rmi registry
Users on other platforms can execute the command the file contains instead (all on one line):
java -ms16m -mx32m RmiJdbc.RJJdbcServer
COM.cloudscape.core.JDBCDriver
After starting the server, you should see startup messages from Cloudscape. If the server starts successfully, the last two messages will say:
COM.cloudscape.core.JDBCDriver registered in DriverManager /RmiJdbcServer bound in rmi registry
java CloudscapeSimpleApp rmijdbcclient
The argument rmijdbcclient indicates that the application should use the RmiJdbc framework. The application also assumes that the server framework is running on localhost at the default port number. Examine the source code for the application to see how it works.
A successful run produces the following output:
CloudscapeSimpleApp starting in rmijdbc mode.
Loaded the appropriate driver.
Connected to and created database CloudscapeDB
Created table CloudscapeDB
Inserted 1956 Webster
Inserted 1910 Union
Updated 1956 Webster to 180 Grand
Updated 180 Grand to 300 Lakeshore
Verified the rows
Dropped table CloudscapeDB
Closed result set and statement
Committed transaction and closed connection
CloudscapeSimpleApp finished
Users on other platforms can execute the Java command that the script contains, instead:
java RJPing
jdbc:rmi:jdbc:cloudscape:;shutdown=true;user=;password= connect
java RJPing jdbc:rmi:jdbc:cloudscape: shutdown
Stopping the server by typing ^C in the server console window means that Cloudscape will have to run recovery on the database the next time it starts up. Avoid this by using the stopCS command to stop the server framework.