home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / template.z / DynamoConnection.wxc < prev    next >
Text File  |  1996-12-09  |  8KB  |  305 lines

  1. Save Format v1.3
  2. @begin ClassFile "DynamoConnection"
  3.  Exported 0;
  4.  Abstract 0;
  5.  Interface 0;
  6.  PackageName "";
  7.  Language "Java";
  8.  
  9.  @begin UserFunction "initDynamoConnection(String arg0)"
  10.  @end;
  11.  
  12.  @begin UserFunction "Prototype for initDynamoConnection(String arg0)"
  13.   Private 1;
  14.   GencodeSrcLine -1;
  15.   FunctionName "DynamoConnection::Prototype for initDynamoConnection(String arg0)";
  16.  @end;
  17.  
  18.  @begin UserFunction "DynamoConnection()"
  19.   GencodeSrcLine 23;
  20.   FunctionName "DynamoConnection::DynamoConnection()";
  21.  @end;
  22.  
  23.  @begin UserFunction "Prototype for DynamoConnection()"
  24.   Private 1;
  25.   GencodeSrcLine -1;
  26.   FunctionName "DynamoConnection::Prototype for DynamoConnection()";
  27.  @end;
  28.  
  29.  @begin UserFunction "getQuery()"
  30.   GencodeSrcLine 43;
  31.   FunctionName "DynamoConnection::getQuery()";
  32.  @end;
  33.  
  34.  @begin UserFunction "Prototype for getQuery()"
  35.   Private 1;
  36.   GencodeSrcLine -1;
  37.   FunctionName "DynamoConnection::Prototype for getQuery()";
  38.  @end;
  39.  
  40.  @begin UserFunction "getHandle()"
  41.   GencodeSrcLine 61;
  42.   FunctionName "DynamoConnection::getHandle()";
  43.  @end;
  44.  
  45.  @begin UserFunction "Prototype for getHandle()"
  46.   Private 1;
  47.   GencodeSrcLine -1;
  48.   FunctionName "DynamoConnection::Prototype for getHandle()";
  49.  @end;
  50.  
  51.  @begin UserFunction "getDocument(int handle)"
  52.   GencodeSrcLine 71;
  53.   FunctionName "DynamoConnection::getDocument(int handle)";
  54.  @end;
  55.  
  56.  @begin UserFunction "Prototype for getDocument(int handle)"
  57.   Private 1;
  58.   GencodeSrcLine -1;
  59.   FunctionName "DynamoConnection::Prototype for getDocument(int handle)";
  60.  @end;
  61.  
  62.  @begin UserFunction "setHandle(int handle)"
  63.   Private 1;
  64.  @end;
  65.  
  66.  @begin UserFunction "Prototype for setHandle(int handle)"
  67.   Private 1;
  68.   GencodeSrcLine -1;
  69.   FunctionName "DynamoConnection::Prototype for setHandle(int handle)";
  70.  @end;
  71.  
  72.  @begin UserFunction "getSession()"
  73.   GencodeSrcLine 77;
  74.   FunctionName "DynamoConnection::getSession()";
  75.  @end;
  76.  
  77.  @begin UserFunction "Prototype for getSession()"
  78.   Private 1;
  79.   GencodeSrcLine -1;
  80.   FunctionName "DynamoConnection::Prototype for getSession()";
  81.  @end;
  82.  
  83.  @begin UserFunction "getConnection()"
  84.   GencodeSrcLine 83;
  85.   FunctionName "DynamoConnection::getConnection()";
  86.  @end;
  87.  
  88.  @begin UserFunction "Prototype for getConnection()"
  89.   Private 1;
  90.   GencodeSrcLine -1;
  91.   FunctionName "DynamoConnection::Prototype for getConnection()";
  92.  @end;
  93.  
  94.  @begin HPPPrefixBlock
  95. @begin-code HPPPrefix
  96.  
  97. // Copyright (c) 1996 Sybase Inc. All rights reserved.
  98.  
  99. /**
  100.  * The DynamoConnection class is a wrapper interface to the NetImpact Dynamo query.
  101.  * DynamoConnection should not be used directly, instead use methods of the predefined
  102.  * document, session, or connection objects.
  103.  *
  104.  * Lifetime: created when the servlet starts.
  105.  * Becomes garbage when the servlet exits.
  106.  *
  107.  * See SQL Anywhere documentation on NetImpact Dynamo for a description
  108.  * of the methods, but be aware that, in Java, the first character
  109.  * of a method name is always in lower case.
  110.  */
  111.  
  112. @end-code;
  113.   GencodeSrcLine 6;
  114.  @end;
  115.  
  116.  @begin CPPPrefixBlock
  117. @begin-code CPPPrefix
  118.  
  119.  
  120. @end-code;
  121.   GencodeSrcLine -1;
  122.  @end;
  123.  
  124.  @begin ClassContentsBlock
  125. @begin-code ClassContents
  126.  
  127.     // add your data members here
  128.     protected static final int CONNECTION = 1000;
  129.     protected static final int DOCUMENT = 1001;
  130.  
  131.     private protected int _dynamoHandle;      // opaque type: handle to Dynamo
  132.     private protected boolean _connected;     // set if initialization succeeded
  133.     private protected static boolean _dllload;  // set when DLL loaded
  134.  
  135. @end-code;
  136.   GencodeSrcLine 93;
  137.  @end;
  138.  
  139. @begin-code BaseClassList
  140.  
  141. extends Object
  142.  
  143. @end-code;
  144.  
  145. @begin-code GeneratedClassContents
  146.  
  147.  
  148. @end-code;
  149.  
  150. @begin-code Code "DynamoConnection::Prototype for initDynamoConnection(String arg0)"
  151.  
  152.     public:
  153.         static native boolean initDynamoConnection(String arg0);
  154.  
  155. @end-code;
  156.  
  157. @begin-code Code "DynamoConnection::DynamoConnection()"
  158.  
  159.     public @CLASSNAME@() {
  160.         _dynamoHandle = -1;
  161.         _dllload = false;
  162.         _connected = false;
  163.     }
  164.     public @CLASSNAME@(int handle) {
  165.         _dynamoHandle = handle;
  166.         _dllload = true;
  167.         _connected = true;
  168.     }
  169.     public @CLASSNAME@(String args[]) {
  170.         if (args.length >= 2 && ! _dllload) {
  171.             // Load connection DLL and keep a private handle to the
  172.             // calling Dynamo requestor
  173.             System.load(args[1]);
  174.     }
  175.         _dynamoHandle = -1;
  176.         _connected = initDynamoConnection(args);
  177.     }
  178.  
  179. @end-code;
  180.  
  181. @begin-code Code "DynamoConnection::Prototype for DynamoConnection()"
  182.  
  183.     public:
  184.         @@CLASSNAME@();
  185.  
  186. @end-code;
  187.  
  188. @begin-code Code "DynamoConnection::getQuery()"
  189.  
  190.     public Query getQuery(String name) throws DynamoException
  191.     {
  192.         // Return a query object referring to named query defined
  193.         // in this template.
  194.         // Throws DynamoException if that query does not yet exist.
  195.         // NOTE: does not yet work -- Dynamo must be altered.
  196.         return new Query(_dynamoHandle, name);
  197.     }
  198.     
  199.     public Query getQuery() throws DynamoException
  200.     {
  201.         // Return the default SQL query object (if it exists).
  202.         // Does not yet work.
  203.         return new Query(_dynamoHandle, "SQL");
  204.     }
  205.     public boolean getConnected() {
  206.         return _connected;
  207.     }
  208.  
  209. @end-code;
  210.  
  211. @begin-code Code "DynamoConnection::Prototype for getQuery()"
  212.  
  213.     public:
  214.         Query getQuery();
  215.  
  216. @end-code;
  217.  
  218. @begin-code Code "DynamoConnection::getHandle()"
  219.  
  220.     public int getHandle()
  221.     {
  222.         return _dynamoHandle;
  223.     }
  224.     protected boolean setHandle(int handle)
  225.     {
  226.         _dynamoHandle = handle;
  227.         _connected = true;
  228.         return true;
  229.     }
  230.  
  231. @end-code;
  232.  
  233. @begin-code Code "DynamoConnection::Prototype for getHandle()"
  234.  
  235.     public:
  236.         int getHandle();
  237.  
  238. @end-code;
  239.  
  240. @begin-code Code "DynamoConnection::getDocument(int handle)"
  241.  
  242.     public Document getDocument()
  243.     {
  244.         // Create a new Document object.
  245.         // Used to create the initial "document" object.
  246.         return new Document(_dynamoHandle);    
  247.     }
  248.  
  249. @end-code;
  250.  
  251. @begin-code Code "DynamoConnection::Prototype for getDocument(int handle)"
  252.  
  253.     public:
  254.         Document getDocument(int handle);
  255.  
  256. @end-code;
  257.  
  258. @begin-code Code "DynamoConnection::Prototype for setHandle(int handle)"
  259.  
  260.     private:
  261.         boolean setHandle(int handle);
  262.  
  263. @end-code;
  264.  
  265. @begin-code Code "DynamoConnection::getSession()"
  266.  
  267.     public Session getSession()
  268.     {
  269.         // Create a new Session object.
  270.         // Used to create the initial (empty) "session" object
  271.         return new Session(_dynamoHandle);    
  272.     }
  273.  
  274. @end-code;
  275.  
  276. @begin-code Code "DynamoConnection::Prototype for getSession()"
  277.  
  278.     public:
  279.         public Session getSession();
  280.  
  281. @end-code;
  282.  
  283. @begin-code Code "DynamoConnection::getConnection()"
  284.  
  285.     public DBConnection getDBConnection()
  286.     {
  287.         // Create a new Connection. Used to create initial "connection" object
  288.         return new DBConnection(_dynamoHandle);   
  289.     }
  290.  
  291.     // Internal native methods.
  292.     protected native String getStringProperty(int id, String property);
  293.     protected native int getIntProperty(int id, String property);
  294.     private native boolean initDynamoConnection(String args[]);
  295.  
  296. @end-code;
  297.  
  298. @begin-code Code "DynamoConnection::Prototype for getConnection()"
  299.  
  300.     public:
  301.         Connection getConnection();
  302.  
  303. @end-code;
  304. @end;
  305.