JavaSP Samples
--------------
1 JavaSP Sample Files Purpose
2 How to Run JavaSP Samples


1 JavaSP Sample Files Purpose
------------------------------

    Sample: 
        C:\DBMaster\5.4\Samples\JavaSP\AddEmployee.java
    Purpose:
        This sample demonstrates how to use JavaSP to insert data 
        with parameters into database.

        1. register dbmaster  driver
        2. connect to database
        3. insert constant data into table sample.employee
        4. close statements
        5. close connection


2 How to Run JavaSP Samples
---------------------------
    Steps:
        1. Check whether Java Development Kit (JDK) is installed 
           on your machine. Because later you need to compile the 
           java method and zip a class using the Javac and Jar tool.
           
        2. Set PATH for the directory of JDKs bin. If you 
           installed the JDK1.3 in C:\jdk1.3.0_02, you should add 
           the directory C:\jdk1.3.0_02\bin to the PATH environment 
           variable.
           
        3. Set CLASSPATH environment variable, make it include the 
           binary files for DBMaster JDBC Driver: dmjdbc20.jar, 
           dmjdbc20xa.jar and dmjdbc30.jar, they are in the directory 
           of C:\DBMaster\5.4\bin. If you have installed DBMaster 5.4 in 
           C:\DBMaster\5.4, so need add the string .;C:\DBMaster\5.4\
           bin\dmjdbc30.jar to CLASSPATH.
           
        4. Start the "DBSAMPLE5" database in client-server mode, 
           and use the dmSQL tool connecting to the DB to manipulate 
           the DB. In later sample, we will use the default user 
           SYSADM as login user.

        5. Set the dmconfig.ini file. You must add the keyword DB_SPDIR 
           for Java stored procedure. If we hope the value of this 
           keyword is C:\DBMaster\5.4\samples\DATABASE\sp, you should 
           make sure the directory is available. Add the following 
           content in the section of "DBSAMPLE5" in the dmconfig.ini file.
           
           DB_SPDIR= C:\DBMaster\5.4\samples\DATABASE\sp
           
        6. Compile the AddEmployee.java file in DOS command line, 
           then it will create the AddEmployee.class file in the 
           current directory.
           
           C:\DBMaster\5.4\samples\JavaSP>javac AddEmployee.java
           
        7. Copy AddEmployee.class to C:\DBMaster\5.4\samples\JavaSP\employee.
        
        8. zip the class, It will create the addEmployee.jar file in 
           the current directory. 
           
           C:\DBMaster\5.4\samples\JavaSP>jar cvf addEmployee.jar 
           employee\AddEmployee.class

        9. Make directory jar\SYSADM in <DB_SPDIR>, Then move the 
           addEmployee.jar file into <DB_SPDIR>\jar\SYSADM.
           
           Note: SYSADM must is uppercase.
          
        10. In dmSQL tool, Using the SQL statement to register 
            the JAR file.
            
            dmSQL>ADD JARFILE addEmployee addEmployee.jar;
            
        11. In dmSQL tool, Using the SQL statement to create the 
            stored procedure.
            
            dmSQL>CREATE PROCEDURE addEmployee(int id,char(12) name) 
            RETURNS STATUS LANGUAGE JAVA FROM 
            'employee.AddEmployee.addEmployee(int,String)',addEmployee;
        
        12. In dmSQL tool, Using the SQL statement to execute the 
            java SP. If the SP executed successfully, the 
            sample.EMPLOYEE table will add a new tuple (123,'SYSADM').

            dmSQL> CALL addEmployee(123,'SYSADM');

        
