KOPI
PrevNext

Chapter 3. XKJC eXtended kopi Java compiler

License type: XKJC is distributed under the terms of the the GNU General Public License. Appendix B

Java with embedded SQL

Our company developes database application written in our own specificatin language (that may be after distributed with a GPL licence). This language allows developer to define triggers and actions in the XKJC language that is a superset of Java with embedded SQL. XKJC allows the mixing of Java-typed expression from both SQL and Java.

Since SQL statements are parsed, it allows one to write a very clear code as compared to JDBC (see XKJC vs JDBC section). It allows onr to make requests with embedded Java expressions computed at runtime. It comes with a support for BLOB and Java serialisation mechanism, allowing to store Java objects in any JDBC database and to retreive them both nicely and efficiently.

As in SQL all types have a NULL value, the distinction between primitive types and Object types of the Java language are problematic. To handle this, XKJC contains an operator overloading capability that allows the mixing of primitive types with objects.

The mechanism of overloading looks like the one provided by C++ compiler except that only expression operator are overidable (+, -, *, /, %, ==, !=, &, |, << >>, >>>, ^, ~, ++, --) and the cast operation. There is no implicit conversion, and that make it easy to understand.

There is an example of a typical XKJC programme:

      #cursor(int id) { 
        SELECT Vector Obj 
        FROM   BLOBS 
        WHERE  ID = :id 
      } typed; 
      typed.open(6); 
      if (typed.next()) 
        for (int i = 0; i < typed.Obj.size(); i++) 
          System.out.println("vect(" + i + "): " + typed.Obj.elementAt(i)); 
      typed.close(); 
    


PrevHomeNext
Road map Java language extensions