I've got a web service (ASMX) that connects to an oracle database and I think my architecture is not the right one.
To access the database I'm using a DLL that has all the database logic and returns completed objects. The oracle connection is created within the DLL, so the database server, user, and pass is hardcoded in the code what I know that cannot be ok. My question is about where to create the connection to the database, and how to configure the server/user/pass parameters in an external configuration file but not to be reading it each time I have to connect to the database.
Right now I have:
ASMX:
- contains the web methods
- validates the request params
- calls the DLL method
DLL:
- creates the database connection (hardcoded constants for the database server/user/password)
- selects data from database
- creates some objects with that data
- closes the connection.
- returns those objects
AMSX:
- process the returned objects from the DLL and returns them.
Should I create the connection in the web methods and store those parameters in a application or session variable, instead of creating them in the dll methods?
Thank you for your help