home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / sys / next / programm / 7926 < prev    next >
Encoding:
Text File  |  1992-12-29  |  2.0 KB  |  73 lines

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!gatech!destroyer!cs.ubc.ca!uw-beaver!news.u.washington.edu!stein.u.washington.edu!bungi
  2. From: bungi@stein.u.washington.edu (Timothy J. Wood)
  3. Newsgroups: comp.sys.next.programmer
  4. Subject: Re: dbkit and sybase server connections
  5. Date: 28 Dec 1992 23:13:58 GMT
  6. Organization: University of Washington
  7. Lines: 61
  8. Message-ID: <1ho1nmINNkt9@shelley.u.washington.edu>
  9. References: <1992Dec28.201019.4259@rdr.com>
  10. NNTP-Posting-Host: stein.u.washington.edu
  11.  
  12. estrin!kswanson (Kevin Swanson) writes:
  13.  
  14. >I'm working on an application that uses dbkit along with sybase.
  15. >I've come across the problem that my application makes two and sometimes
  16. >three connections to the sybase server, when it really should only need
  17. >a single connection.
  18.  
  19. >Has anyone who has worked with dbkit experienced any problems like this?
  20.  
  21.   Yes, actually.  The problem is that DBBinder defaults to use non-shared
  22. context (this is where the connection is stored) when you really want it to
  23. share the context.  You can set the context sharing with 
  24.  
  25.   [aBinder setSharesContext: flag];
  26.  
  27.   What I did to get around this problem was to impelement a subclass of
  28. DBBinder called SharedBinder that goes something like:
  29.  
  30. #import <dbkit/dbkit.h>
  31.  
  32. @interface SharedBinder : DBBinder
  33. {
  34. }
  35. - init;
  36. - setSharesContext: (BOOL) flag
  37. @end
  38.  
  39. @implementation SharedBinder
  40. - init
  41. {
  42.   return [[super init] setSharesContext: YES];
  43. }
  44.  
  45. - setSharesContext: (BOOL) flag
  46. {
  47.   return [super setSharesContext: YES];
  48. }
  49. @end
  50.  
  51.    To get this to effect the binders that DBKit sets up for you, you will
  52. have to do a:
  53.  
  54.    [SharedBinder poseAs: [DBBinder class]];
  55.  
  56.   before they are allocated.  The best place is probably in you *_main.m
  57. file or in your appWillInit: method. 
  58.    
  59.    You will want to note that sharing context with other DBBinders disables
  60. flushing.  I haven't experienced any problems with this, but depending upon
  61. what you are doing, you might.
  62.  
  63. >thanks,
  64. >kevin
  65.  
  66.  
  67. >kswanson@rdr.com
  68.  
  69.  
  70. Timothy J. Wood
  71. The Omni Group
  72. DBKit Consulting
  73.