1
                                                                    Exhibit 99.2


                             STOCKHOLDERS AGREEMENT

         Stockholders Agreement (this "Agreement"), dated as of April 17, 2000,
among Sanmina Corporation, a Delaware corporation ("Parent"), and the
stockholders of Hadco Corporation, a Massachusetts corporation (the "Company"),
listed on Schedule A hereto (the "Stockholders").

         WHEREAS, concurrently with the execution of this Agreement, Parent,
SANM Acquisition Subsidiary, Inc., a Massachusetts corporation and a wholly
owned subsidiary of Parent ("Sub"), and the Company have entered into an
Agreement and Plan of Merger (as the same may be further amended from time to
time, the "Merger Agreement"), providing for the merger (the "Merger") of Sub
with and into the Company pursuant to the terms and conditions of the Merger
Agreement; and

         WHEREAS, the Stockholders own of record and beneficially the shares
(the "Shares") of the common stock, $0.05 par value, of the Company (the
"Company Common Stock") set forth opposite their respective names on Schedule A
hereto and wish to enter into this Agreement with respect to the Shares; and

         WHEREAS, in order to induce Parent and Sub to enter into the Merger
Agreement, the Stockholders have agreed, upon the terms and subject to the
conditions set forth herein, to vote the Shares at a meeting of the Company's
stockholders in favor of approval of the Merger.

         NOW, THEREFORE, for good and valuable consideration, the receipt,
sufficiency and adequacy of which is hereby acknowledged, the parties hereto
agree as follows:

      1.    Agreement To Vote Shares.

            (a) Subject to Section 1(b) hereof, each of the Stockholders agrees
during the term of this Agreement to vote the Shares as to which it has voting
power or control, in person or by proxy, in favor of approval of the Merger at
the meeting of the stockholders of the Company at which such matter is
considered and at any adjournment thereof (the "Stockholder Meeting"); provided,
however, that for purposes of Section 1 hereof, Shares shall not include any
shares of Company Common Stock that a Stockholder may acquire upon the exercise
of any stock option unless such option has been exercised and such shares of
Company Common Stock have been issued to the Stockholder and are held by the
Stockholder as of the relevant record date.

            (b) Notwithstanding anything to the contrary contained herein, the
obligations of the Stockholders pursuant to Section 1(a) hereof with respect to
such matter to be considered at the Stockholder Meeting are subject to the
following conditions:

                  (i) Parent shall have performed in all material respects all
of its material obligations under the Merger Agreement to have been performed at
or prior to the date of such Stockholder Meeting;
   2
                  (ii) there shall not be in effect on the date of such
Stockholder Meeting any statute, rule, regulation, order or injunction of a
court of competent jurisdiction or governmental authority directing that the
transactions contemplated by the Merger Agreement not be consummated; and

                  (iii) the Form S-4 (as defined in the Merger Agreement) to be
filed with the Securities and Exchange Commission (the "Commission") by Parent
under the Securities Act of 1933, as amended (the "Act"), to register the common
shares, $0.01 par value, of Parent to be issued in the Merger shall have become
effective under the Act and shall not be the subject of any stop order or
proceeding by the Commission seeking a stop order.

         2. No Voting Trusts. Except for such agreements or arrangements in
effect as of the date hereof, each of the Stockholders agrees that such
Stockholder shall not, nor shall such Stockholder permit any entity under such
Stockholder's control to, deposit any of such Stockholder's Shares in a voting
trust or subject any of its Shares to any arrangement with respect to the voting
of the Shares inconsistent with this Agreement.

         3. Limitation On Dispositions And Proxies. During the term of this
Agreement, each of the Stockholders agrees not to sell, assign, pledge, transfer
or otherwise dispose of (each a "Transfer"), or grant any proxies with respect
to (except for a proxy which is not inconsistent with the terms of this
Agreement) any of such Stockholder's Shares; provided, however, a Stockholder
may transfer any or all of the Shares (or any interest therein) to one or more
members of the Stockholder's family, any trust for the benefit of the
Stockholder's family or any entity controlled by the Stockholder so long as the
transferee of such Shares agrees in writing to be bound by the applicable
provisions of this Agreement.

         4. Specific Performance. Each party hereto acknowledges that it shall
be impossible to measure in money the damage to the other party if a party
hereto fails to comply with the obligations imposed by this Agreement, and that,
in the event of any such failure, the other party shall not have an adequate
remedy at law or in damages. Accordingly, each party hereto agrees that
injunctive relief or other equitable remedy, in addition to remedies at law or
damages, is the appropriate remedy for any such failure and shall not oppose the
granting of such relief on the basis that the other party has an adequate remedy
at law. Each party hereto agrees that it shall not seek, and agrees to waive any
requirement for, the securing or posting of a bond in connection with any other
party's seeking or obtaining such equitable relief.

         5. Term Of Agreement; Termination. The term of this Agreement shall
commence on the date hereof, and such term and this Agreement shall terminate
upon the earliest to occur of (i) the Effective Time; (ii) the date on which the
Merger Agreement is terminated in accordance with its terms; and (iii) September
30, 2000, provided however that such date shall be automatically extended to
November 15, 2000 in the event that such date is automatically extended pursuant
to Section 7.1(b)(i) of the Merger Agreement. Upon such termination, no party
shall have any further obligations or liabilities hereunder; provided, however,
that such termination shall not relieve any party from liability for any breach
of this Agreement prior to such termination.

         6. Entire Agreement. This Agreement supersedes all prior agreements,
written or oral, among the parties hereto with respect to the subject matter
hereof and contains the entire agreement among the parties with respect to the
subject matter hereof. This Agreement may not be amended, supplemented or
modified, and no provisions hereof may be modified or waived, except by an
instrument


                                      -2-
   3
in writing signed by all parties hereto. No waiver of any provisions hereof by
any party shall be deemed a waiver of any other provisions hereof by any such
party, nor shall any such waiver be deemed a continuing waiver of any provision
hereof by such party.

         7. Notices. All notices, consents, requests, instructions, approvals
and other communications provided for herein shall be in writing and shall be
deemed to have been duly given if mailed, by first class or registered mail,
three (3) business days after deposit in the United States mail, or if telexed
or telecopied, sent by telegram, or delivered by hand or reputable overnight
courier, when confirmation is received, in each case as follows:

         If to the Stockholders, to the addresses listed on Schedule A hereto.

         With a copy to:

                  Hadco Corporation
                  12A Manor Parkway
                  Salem, NH  03079
                  Attention:  General Counsel

                  and

                  Testa, Hurwitz & Thibeault, LLP
                  125 High Street
                  Boston, MA 02110
                  Attention:  Stephen A. Hurwitz, Esq.

         If to Parent:

                  Sanmina Corporation
                  2700 North First Street
                  San Jose, CA  95134
                  Attention:  President

         With a copy to:

                  Wilson Sonsini Goodrich & Rosati Professional Corporation
                  650 Page Mill Road
                  Palo Alto, CA  94304
                  Attention:  Christopher D. Mitchell, Esq.

or to such other persons or addresses as may be designated in writing by the
party to receive such notice. Nothing in this Section 7 shall be deemed to
constitute consent to the manner and address for service of process in
connection with any legal proceeding (including litigation arising out of or in
connection with this Agreement), which service shall be effected as required by
applicable law.

                                      -3-
   4
      8. Miscellaneous. This Agreement shall be deemed a contract made under,
and for all purposes shall be construed in accordance with, the laws of the
State of Delaware, without reference to its conflicts of law principles.

         ( a) If any provision of this Agreement or the application of such
provision to any person or circumstances shall be held invalid or unenforceable
by a court of competent jurisdiction, such provision or application shall be
unenforceable only to the extent of such invalidity or unenforceability, and the
remainder of the provision held invalid or unenforceable and the application of
such provision to persons or circumstances, other than the party as to which it
is held invalid, and the remainder of this Agreement, shall not be affected.

         (b) This Agreement may be executed (including by facsimile
transmission) in one or more counterparts, each of which shall be deemed to be
an original but all of which together shall constitute one and the same
instrument.

         (c) All Section headings herein are for convenience of reference only
and are not part of this Agreement, and no construction or reference shall be
derived therefrom.

         (d) The obligations of the Stockholders set forth in this Agreement
shall not be effective or binding upon the Stockholders until after such time as
the Merger Agreement is executed and delivered by the Company, Parent and Sub.

         (e) Nothing in this Agreement shall, and nothing in this Agreement
shall be deemed to, limit or restrict a Stockholder from acting in accordance
with his or her duties as a director or officer of the Company or otherwise
limit the ability of the Stockholder to take any action in his or her capacity
as a director or officer of the Company.


                                      -4-
   5
         IN WITNESS WHEREOF, the parties hereto have executed and delivered this
Agreement as of the date first written above.

                                           PARENT:

                                           Sanmina Corporation

                                           By: /s/ Jure Sola
                                           -----------------------------------

                                           STOCKHOLDERS:

                                           /s/ Horace H. Irvine II
                                           -----------------------------------
                                           Horace H. Irvine II

                                           /s/ Andrew E. Lietz
                                           -----------------------------------
                                           Andrew E. Lietz

                                           /s/ Oliver O. Ward
                                           -----------------------------------
                                           Oliver O. Ward

                                           /s/ John F. Smith
                                           -----------------------------------
                                           John F. Smith

                                           /s/ John E. Pomeroy
                                           -----------------------------------
                                           John E. Pomeroy

                                           /s/ James C. Taylor
                                           -----------------------------------
                                           James C. Taylor

                                           /s/ Mauro J. Walker
                                           -----------------------------------
                                           Mauro J. Walker

                                           /s/ Gilbert M. Roody, Jr.
                                           -----------------------------------
                                           Gilbert M. Roddy, Jr.

                                           /s/ F. Gordon Bitter
                                           -----------------------------------
                                           F. Gordon Bitter
   6
                                   SCHEDULE A



                                    NUMBER OF SHARES                          NUMBER OF UNEXERCISED
                                       OWNED AS OF       SHARES STOCKHOLDER      OPTIONS AS
NAME AND ADDRESS OF STOCKHOLDER     APRIL 17, 2000(1)    HAS RIGHT TO VOTE    OF APRIL 17, 2000
- -------------------------------     -----------------    -----------------    -----------------
                                                                     
Horace H. Irvine, II                  670,407               19,355(2)                   0
27 Gordon Mountain Road
Windham, NH 03087

Andrew E. Lietz                        83,601                     0               289,000
47 Spring Road
Rye, NH 03870

Oliver O. Ward                          1,387                     0                12,000
Garnet Hill Road
Sunapee, NH 03782

John F. Smith                          26,887                     0                 3,000
11 Samuel Parlin Drive
Acton, MA 01720

John E. Pomeroy                         4,387                     0                15,000
416 Murray Hill Road
Vestal, NY 13850

James C. Taylor                         6,387                     0                15,000
14 Lawrence Road
Chestnut Hill, MA 02167

Mauro J. Walker                         1,329                     0                15,000
108 Dolphin Drive
Ocean Ridge, FL 33435

Gilbert M. Roddy, Jr                      745                42,605(3)             15,000
101 Barnes Hill Road
Concord, MA 01742

F. Gordon Bitter                        3,573                     0                28,500
17 Cotton Farm Lane
No. Hampton, NH 03862


- --------

     (1)    Includes shares deferred under the Outside Directors' Compensation
            Plans of 1998 and 2000.

     (2)    Shares of Andrea Irvine, held in a voting trust for her benefit.
            (See the Company's Proxy Statement dated January 14, 2000).

     (3)    Mr. Roddy is co-trustee of certain irrevocable trusts for the
            benefit of certain of Mr. Irvine's family. (See the Company's Proxy
            Statement dated January 14, 2000).