czwartek, grudnia 13, 2007

Informix z Javą

  1. Świetny help z IBM - należy zrobić nastepujące rzeczy:
    1. Stworzyć plik w javie - jako klasę statyczną np: public static int explosiveReaction(int ingredient);
    2. Powstanie wtedy klasa np Courses w pliku jar: - /students/data/Courses.jar
    3. Należy ją zainstalować w bieżącej bazie -
      EXECUTE PROCEDURE     sqlj.install_jar("file://students/data/Courses.jar", "course_jar")
    4. Inne polecenia to: sql.remove_jar, sql.replace_jar, sql.alter_java_path
    5. Jest jeszcze pojęcie External Routine Reference które mapuje nazwy:
    6. EXTERNAL NAME "wskaznikDoPlikuJar.jar" LANGUAGE JAVA
    7. Więcej o tej ostatniej:
    8. EXECUTE PROCEDURE alter_java_path("course_jar",     "(professor/*, prof_jar)"); EXECUTE FUNCTION sql_explosive_reaction(10000)
    9. Powyższe oznacza, że będzie przeszukiwana dodatkowa biblioteka w katalogu professor w celu znalezienia pakietu prof_jar.       
    10. Dostajemy wtedy tzw. jar ID (course_jar), który może służyć jako odnośnik w UDR napisanych w javie.
    11. Trzeci parametr pozwala na wykonanie dodatkowych funkcji (w postaci zdań SQL) np. zarejestrowanie i przydzielenia grantów (przywilejów) dla tego UDR.
    12. Przykład wywołanie funkcji w C:
    13. CREATE FUNCTION equal( a point, b point ) RETURNING BOOLEAN;    EXTERNAL NAME "/usr/lib/point/lib/libbtype1.so(point1_equal)"    LANGUAGE C END FUNCTION;
    14. Fragment dokumentacji orginalnej:
      To create a user-defined function written in the Java language 
      1. Write a Java static method, which can use the JDBC functions to interact with the database server.
      2. Compile the Java source file and create a .jar file (the shared-object file for Java).
      3. Execute the install_jar( ) procedure with the EXECUTE PROCEDURE statement to install the jar file in the current database.
      4. If the UDR uses user-defined types, create a map between SQL data types and Java classes.
      5. Use the setUDTExtName( ) procedure that is explained in EXECUTE PROCEDURE.
      6. Register the UDR with the CREATE FUNCTION statement.

      Rather than storing the body of an external routine directly in the database, the database server stores only the pathname of the shared-object file that contains the compiled version of the routine. When it executes the external routine, the database server invokes the external object code.

      The database server stores information about an external function in system catalog tables, including sysprocbody and sysprocauth. For more information on the system catalog, see the IBM Informix Guide to SQL: Reference.

    1. Bardzo ciekawie wygląda opcja szyfrowania danych - http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqls.doc/sqls1024.htm - w Informixie

Brak komentarzy: