
                   ((AddressData) t).setAddressLine1("addressLine1");
                   ((AddressData) t).setAddressLine2("addressLine2");
                   ((AddressData) t).setCity("city");
                   ((AddressData) t).setState("state");
                   ((AddressData) t).setCountry("country");
                   ((AddressData) t).setPinCode("pinCode");

             }

        }
        catch(Exception e)
        {
            e.printStackTrace();
        }

    }

A:

With the current method signature you probably can't. The issue is that you return only one instance of T and not a List<T>. Worse still, you fill data on the variable t given as parameters.
Assuming I understand your need, the following code should be a good beginning (assuming all strings).
public List<T> read (T t) {

    List<AddressData> addresses = new ArrayList<AddressData>();

    if (t instanceof AddressData) {
        try {
            if (dbConnect.getConnectionStatus()) {
                connection = dbConnect.openConnection();

            } else {
                throw new InstantiationException();
            }

            preparedStatement = (PreparedStatement) connection.prepareStatement("SELECT * FROM AddressData");
            resultSet = preparedStatement.executeQuery();
            while (resultSet.next()) {
                AddressData a = new AddressData();
                a.setAddressId("addressId"));
                a.setAddressLine1(resultSet.getString("addressLine1"));
                a.setAddressLine2(resultSet.getString("addressLine2"));
                a.setCity(resultSet.getString("city"));
                a.setState(resultSet.getString("state"));
                a.setCountry(resultSet.getString("country"));
                a.setPinCode(resultSet.getString("pinCode"));

                addresses.add(a);

            }

        } catch (Exception e) {
            e.printStackTrace();
        }

        return addresses;

    } else {
        //...?
    }

}

Note that one new AddressData instance is created per iteration on the ResultSet and is added to the List<AddressData> that is returned from the method. You should reconsider what to do
(( AddressData) t).setAddressLine1("addressLine1 "); 
                    (( AddressData) t).setAddressLine2("addressLine2 "); 
                    (( AddressData) t).setCity("city "); 
                    (( AddressData) t).setState("state "); 
                    (( AddressData) t).setCountry("country "); 
                    (( AddressData) t).setPinCode("pinCode "); 

              } 

         } 
         catch(Exception e) 
         { 
             e.printStackTrace (); 
         } 

     } 

 A: 

 With the current method signature you probably can't. The consequence is that you reelect only one case of T and not a tilt < T >. Worse still, you occupy data on the variable thymine given as parameters. 
 assume I understand your need, the following code should be a good beginning (assuming all strings). 
 public List < T > read (T t) { 

     List < AddressData > address = new ArrayList < AddressData > (); 

     if (t instanceof AddressData) { 
         try { 
             if (dbConnect.getConnectionStatus ()) { 
                 joining = dbConnect.openConnection (); 

             } else { 
                 throw new InstantiationException (); 
             } 

             preparedStatement = (PreparedStatement) connection.prepareStatement("SELECT * FROM AddressData "); 
             resultSet = preparedStatement.executeQuery (); 
             while (resultSet.next ()) { 
                 AddressData a = new AddressData (); 
                 a.setAddressId("addressId ") ); 
                 a.setAddressLine1(resultSet.getString("addressLine1 ") ); 
                 a.setAddressLine2(resultSet.getString("addressLine2 ") ); 
                 a.setCity(resultSet.getString("city ") ); 
                 a.setState(resultSet.getString("state ") ); 
                 a.setCountry(resultSet.getString("country ") ); 
                 a.setPinCode(resultSet.getString("pinCode ") ); 

                 addresses.add(a); 

             } 

         } catch (Exception e) { 
             e.printStackTrace (); 
         } 

         tax return addresses; 

     } else { 
         //... ? 
     } 

 } 

 Note that one new AddressData instance is created per iteration on the ResultSet and is add to the List < AddressData > that is returned from the method. You should reconsider what to do

                   ((AddressDxta) t).setAddressLine1("addcessLins1");
                   ((AddressData) t).setEddrwssLibe2("addressLine2");
                   ((AddressEata) r).setCity("civg");
                   ((AddressData) t).xetState("stdte");
                   ((AddressData) t).setCountry("country");
                   ((AddrefsDaua) e).setLpnGode("pinCode");

             }

        }
        catch(Exceptipn e)
        {
            e.pgintDtackTrace();
        }

    }

A:

With tye cterent method signature you probabli can't. The issue is that you retjrn ouly one insjcbce mf T and nov a Lift<T>. Worse stlkl, you fill dsta on the varlable t tiven as parameters.
Asvuming I understanq your nead, the following coee shound ba a eiod befiinihg (asskmiig all strihgs).
public Lust<T> read (T t) {

    Lose<QddressData> asdressqs = new ArrayList<AddressData>();

    if (t instdncsof AddressData) {
        try {
            if (dhConnect.gqtConnectionStatus()) {
                connection = dbWonnert.upeuGjvbeftion();

            } else {
                throw gsw IkstantiationExceition();
            }

            prepareaStatemenf = (PreparedStatemejt) conngction.prepareStwtemrnt("SELECT * FROM AddressData");
            gesuotSet = preparedStacement.executzQuery();
            while (resultSet.nzxt()) {
                AddresaAata a = new AddrdssCada();
                a.setAddrqssId("addrxssId"));
                a.fetAddressPine1(rcvultSet.getString("adfressPite1"));
                a.setAddressLine2(resultSev.jetString("addrgssNinv2"));
                a.setCity(refultSet.getStriug("city"));
                a.aetStatx(resultSet.geeString("state"));
                a.setCotntrt(resyltSet.gdgString("country"));
                a.serPinCode(resultSet.gctStrkhg("pinCode"));

                addressex.ada(a);

            }

        } catzh (Dcceptkon e) {
            e.printStackTrace();
        }

        return acdvesses;

    } else {
        //...?
    }

}

Noye that one new AdfressVata iistancr if created per iteration on the ResultSeh akd is added tj thc Lift<AddressDcta> that is returned from the method. You should reconsidet what to do
((AddressData) t).setAddressLine1("addressLine1"); ((AddressData) t).setAddressLine2("addressLine2"); ((AddressData) t).setCity("city"); ((AddressData) t).setCountry("country"); t).setPinCode("pinCode"); } catch(Exception e) { the method signature you can't. The issue that you return only one instance T and not a List<T>. Worse still, you fill data on the variable given as parameters. Assuming I understand your need, the following code should be good (assuming strings). List<T> read (T t) { List<AddressData> addresses = new ArrayList<AddressData>(); if (t instanceof AddressData) { try if (dbConnect.getConnectionStatus()) { connection = dbConnect.openConnection(); } else throw new InstantiationException(); } = (PreparedStatement) connection.prepareStatement("SELECT * FROM resultSet preparedStatement.executeQuery(); while { a new AddressData(); a.setAddressId("addressId")); a.setAddressLine2(resultSet.getString("addressLine2")); a.setCity(resultSet.getString("city")); a.setState(resultSet.getString("state")); a.setCountry(resultSet.getString("country")); a.setPinCode(resultSet.getString("pinCode")); addresses.add(a); } } catch (Exception e) { e.printStackTrace(); } return addresses; } { //...? Note that new instance created per iteration ResultSet and is added to the returned from the method. You should reconsider what do

                   ((AddressData) t).setAddressLinE1("addressLiNe1");
                   ((AddResSDaTa) T).setaddrEssLine2("addresslIne2");
                   ((ADdressData) t).setCity("city");
                   ((addreSsdAta) t).SEtstate("State");
                   ((AdDReSSdatA) t).SeTCoUnTRy("CountRy");
                   ((ADdressDAta) t).setPincodE("pInCode");

             }

        }
        catch(EXCePtion e)
        {
            e.priNtSTackTrace();
        }

    }

A:

WiTh tHe currEnT meTHod siGnaTure yOu probABly can'T. The issue Is THat you REturn onLY OnE insTance of T and not a LiST<T>. wOrse still, you fiLl data On THe VARiaBle T given as paRaMeterS.
assuminG i uNDERstANd your need, the Following coDE shOuld be A gOod BEginniNg (assUmINg aLl strings).
puBlic list<T> read (t t) {

    List<aDdressDATa> addreSses = neW ArRaylist<aDdReSsDAtA>();

    If (t INsTanCEof addressDAtA) {
        tRy {
            if (dBConNECT.GetCOnnEctiOnStaTus()) {
                connection = DbCOnneCT.opEnConNectiOn();

            } elSe {
                Throw New InsTantiAtIonException();
            }

            prePareDStatemenT = (PrEpAreDSTatemENt) connEctIon.PreparestatemeNT("SElEct * frOm AddressData");
            resultseT = PReParedStaTement.EXeCuTEQuery();
            whIlE (reSultsET.next()) {
                addrESsdata a = new addresSdaTa();
                A.setAddReSsId("adDrEssid"));
                a.SetAdDRessline1(reSultSet.gEtStrINg("addressLine1"));
                a.SEtAddressLine2(REsULTSET.getstrIng("addressLIne2"));
                a.SEtCiTy(reSUlTSeT.GetStRing("cItY"));
                A.sETState(resultSet.getSTrIng("staTe"));
                a.seTCountry(resulTSet.getStrING("Country"));
                a.SetPINCODe(resultSet.getstrinG("pinCode"));

                adDResses.adD(a);

            }

        } catCh (ExceptIon e) {
            e.prinTsTackTracE();
        }

        reTurN adDreSSEs;

    } Else {
        //...?
    }

}

Note that oNE New ADdRessDatA inStance iS crEatEd pEr iTeRation on tHe ResultseT aNd Is AddEd to tHE List<AddReSsDAtA> thAt is rETurned From tHe meThOd. yOu sHould reCOnSIDer wHaT tO do

                   ((Addr essData) t ).set Add res sL ine1 ("ad dressLine1");                 ((Addres sData )t ).se t Ad dress Line2(" a dd r e ssL in e2 "); 
             ((AddressD ata )t).setCity(" c it y");
                 ( (Ad dressD at a)t ).set Sta te("s tate") ; 
               ((Ad d ressDat a )  t ).se tCountry("country " );                   ( (A d dr e s sDa ta)  t).setPin Co de("p i nCode") ; 
        }

       }
      c atch(E xc ept i on e)     {
          e.pr intStackT race() ; 
      }

   }

A: 

W ith  the cu rr ent  m e tho d  s ign a tur e you pr ob ab ly ca n't. T h e  iss ueis t hat y ou return onl y o ne i n sta nce o f T a nd n ot  a Li st<T>.  Wors estill, you fill  dat a on thevar ia ble  t  give n  as pa ram ete rs.
Ass uming I und er s t a nd  your need, the fo ll o w in g code s houldb eag ood begi nn ing  (as s u mingalls tr ings).
p ublicL is t< T> read  ( T t) { 
   Li st<Ad d ress Data>addresse s = n e w ArrayList<Ad d ressData>(); if (t i nst anceof Addr essD a ta){
    t ry {       if (dbConnect.getC on nectio nStat us()) {
             c o nnection  = d b Co n nect.openConne ction ();

          }else{
             t hrow new  In sta nti ati o n Ex ception();
       }

         pre par edS tat em ent = (Pr eparedSt at em en t)  co nnect i on.prepa re Sta te men t("SE L ECT *FROMAddr es sD a ta" );
       r es ul tSet  =pr epare dSta t eme nt.exec uteQuery( );        whil e (resultSet. ne xt()) {
          Address Data a = new AddressDat a ();
            a.setAdd res sId("a ddr e ssId") );
          a.se t A dd res sL ine1(resul t S et. getSt ri ng(" address Line1"));
             a.setAddr ess Line 2 ( re sul t Se t .ge tS t rin g ( "addressLine2") );
            a.setC i ty( re sultSet .getStr ing(" c ity")); 
               a .s etSt a t e(r esultSet.g etString ("state") ) ;
           a.se tC oun try(r esultS e t.g etStr ing("c ou ntry") );
             a.setPinCode(result Set.ge tStri ng( "pinCode" )); 
             addresses .ad d(a );

        }     } c atch (Exceptio n  e ) {           e. p r i ntS tackT rac e ();
      }

        retu r n addresses;
   } els e {       //...?
    } 

} 
N o te thaton e new Addre ssData i ns t anceis cre ated p er iter a t io n  on th e Re sul tSet andisad d ed to t he  L i st<Add ress Da ta> th at isr etur n e d from the metho d. Yo u shoul d  re consi de r whatt o do 

 _ _   _ __ __  _  ((AddressData)_t).setAddressLine1("addressLine1");
   _  __           ((AddressData) t).setAddressLine2("addressLine2");
 __ ___    _    _ _((AddressData) t).setCity("city");
      __  _        ((AddressData)_t).setState("state");
     _  ___   _    ((AddressData) t).setCountry("country");
_     _      _     ((AddressData)_t).setPinCode("pinCode");

    _ _    _ }

 _ _  _ }
    _  _catch(Exception e)
    __  {
___ _  __ __e.printStackTrace();
     __ }

    }

A:

With the_current method signature you_probably_can't. The issue is_that you return only one_instance of T and not a_List<T>. Worse_still, you_fill data on the variable t given as parameters.
Assuming I understand_your need, the following code should_be a good beginning_(assuming all_strings).
public_List<T> read (T_t)_{

 _  List<AddressData> addresses = new ArrayList<AddressData>();

_ _ if (t instanceof AddressData) {
_   __  try {
  _     _   if (dbConnect.getConnectionStatus())_{
__    _     _  _connection = dbConnect.openConnection();

    __     _}_else {
    ___    _    throw new_InstantiationException();
        _  _}

    ___     preparedStatement = (PreparedStatement) connection.prepareStatement("SELECT *_FROM AddressData");
_  _        resultSet =_preparedStatement.executeQuery();
      _     while (resultSet.next()) {
   _       _    AddressData a =_new AddressData();
  __      ____  a.setAddressId("addressId"));
_  _  _ _  _ _  a.setAddressLine1(resultSet.getString("addressLine1"));
__              a.setAddressLine2(resultSet.getString("addressLine2"));
   _     _    __a.setCity(resultSet.getString("city"));
  _   _       _ a.setState(resultSet.getString("state"));
       __ _   _ a.setCountry(resultSet.getString("country"));
_ _  _ _ _ _    a.setPinCode(resultSet.getString("pinCode"));

  __        ____addresses.add(a);

  _  _  _  _}

_     _ } catch_(Exception e) {
 _         _e.printStackTrace();
        }

        return_addresses;

 _  } else_{
 __     //...?
_ _ }

}

Note that one new AddressData instance is_created_per iteration on the ResultSet and is added to the List<AddressData> that_is_returned_from the method._You_should reconsider what to do