home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / samples.z / DynamoConnection.wxc < prev    next >
Text File  |  1997-01-28  |  7KB  |  297 lines

  1. Save Format v2.0(1)
  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 42;
  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 60;
  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 70;
  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 76;
  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 82;
  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 ClassContentsBlock
  117. @begin-code ClassContents
  118.  
  119.     // add your data members here
  120.     protected static final int CONNECTION = 1000;
  121.     protected static final int DOCUMENT = 1001;
  122.  
  123.     private protected int _dynamoHandle;      // opaque type: handle to Dynamo
  124.     private protected boolean _connected;     // set if initialization succeeded
  125.     private protected static boolean _dllload;  // set when DLL loaded
  126.  
  127. @end-code;
  128.   GencodeSrcLine 92;
  129.  @end;
  130.  
  131. @begin-code BaseClassList
  132.  
  133. extends Object
  134.  
  135. @end-code;
  136.  
  137. @begin-code GeneratedClassContents
  138.  
  139.  
  140. @end-code;
  141.  
  142. @begin-code Code "DynamoConnection::Prototype for initDynamoConnection(String arg0)"
  143.  
  144.     public:
  145.         static native boolean initDynamoConnection(String arg0);
  146.  
  147. @end-code;
  148.  
  149. @begin-code Code "DynamoConnection::DynamoConnection()"
  150.  
  151.     public @CLASSNAME@() {
  152.         _dynamoHandle = -1;
  153.         _dllload = false;
  154.         _connected = false;
  155.     }
  156.     public @CLASSNAME@(int handle) {
  157.         _dynamoHandle = handle;
  158.         _dllload = true;
  159.         _connected = true;
  160.     }
  161.     public @CLASSNAME@(String args[]) {
  162.         if (args.length >= 2 && ! _dllload) {
  163.             // Load connection DLL and keep a private handle to the
  164.             // calling Dynamo requestor
  165.             System.load(args[1]);
  166.     }
  167.         _dynamoHandle = -1;
  168.         _connected = initDynamoConnection(args);
  169.     }
  170.  
  171. @end-code;
  172.  
  173. @begin-code Code "DynamoConnection::Prototype for DynamoConnection()"
  174.  
  175.     public:
  176.         @@CLASSNAME@();
  177.  
  178. @end-code;
  179.  
  180. @begin-code Code "DynamoConnection::getQuery()"
  181.  
  182.     public Query getQuery(String name) throws DynamoException
  183.     {
  184.         // Return a query object referring to named query defined
  185.         // in this template.
  186.         // Throws DynamoException if that query does not yet exist.
  187.         // NOTE: does not yet work -- Dynamo must be altered.
  188.         return new Query(_dynamoHandle, name);
  189.     }
  190.  
  191.     public Query getQuery() throws DynamoException
  192.     {
  193.         // Return the default SQL query object (if it exists).
  194.         // Does not yet work.
  195.         return new Query(_dynamoHandle, "SQL");
  196.     }
  197.     public boolean getConnected() {
  198.         return _connected;
  199.     }
  200.  
  201. @end-code;
  202.  
  203. @begin-code Code "DynamoConnection::Prototype for getQuery()"
  204.  
  205.     public:
  206.         Query getQuery();
  207.  
  208. @end-code;
  209.  
  210. @begin-code Code "DynamoConnection::getHandle()"
  211.  
  212.     public int getHandle()
  213.     {
  214.         return _dynamoHandle;
  215.     }
  216.     protected boolean setHandle(int handle)
  217.     {
  218.         _dynamoHandle = handle;
  219.         _connected = true;
  220.         return true;
  221.     }
  222.  
  223. @end-code;
  224.  
  225. @begin-code Code "DynamoConnection::Prototype for getHandle()"
  226.  
  227.     public:
  228.         int getHandle();
  229.  
  230. @end-code;
  231.  
  232. @begin-code Code "DynamoConnection::getDocument(int handle)"
  233.  
  234.     public Document getDocument()
  235.     {
  236.         // Create a new Document object.
  237.         // Used to create the initial "document" object.
  238.         return new Document(_dynamoHandle);    
  239.     }
  240.  
  241. @end-code;
  242.  
  243. @begin-code Code "DynamoConnection::Prototype for getDocument(int handle)"
  244.  
  245.     public:
  246.         Document getDocument(int handle);
  247.  
  248. @end-code;
  249.  
  250. @begin-code Code "DynamoConnection::Prototype for setHandle(int handle)"
  251.  
  252.     private:
  253.         boolean setHandle(int handle);
  254.  
  255. @end-code;
  256.  
  257. @begin-code Code "DynamoConnection::getSession()"
  258.  
  259.     public Session getSession()
  260.     {
  261.         // Create a new Session object.
  262.         // Used to create the initial (empty) "session" object
  263.         return new Session(_dynamoHandle);    
  264.     }
  265.  
  266. @end-code;
  267.  
  268. @begin-code Code "DynamoConnection::Prototype for getSession()"
  269.  
  270.     public:
  271.         public Session getSession();
  272.  
  273. @end-code;
  274.  
  275. @begin-code Code "DynamoConnection::getConnection()"
  276.  
  277.     public DBConnection getDBConnection()
  278.     {
  279.         // Create a new Connection. Used to create initial "connection" object
  280.         return new DBConnection(_dynamoHandle);   
  281.     }
  282.  
  283.     // Internal native methods.
  284.     protected native String getStringProperty(int id, String property);
  285.     protected native int getIntProperty(int id, String property);
  286.     private native boolean initDynamoConnection(String args[]);
  287.  
  288. @end-code;
  289.  
  290. @begin-code Code "DynamoConnection::Prototype for getConnection()"
  291.  
  292.     public:
  293.         Connection getConnection();
  294.  
  295. @end-code;
  296. @end;
  297.