Database connection setup across all modules of a big java project -
Database connection setup across all modules of a big java project -
in big project set database connection available across modules?
suppose requirement this:
loginpage.html -> loginservlet.java -> loginservice.java ==> takes db help check credentials.
now, since actual credentials stored in db, set database connection available modules?
in big projects, database connection made , when needed or database connections setup @ time when application run , made available across modules.
if db connections made available modules (which need db connectivity), how achieved?
thanks help , inputs.
since you're not using ioc approach (spring), alternative have static class (or singleton) has reference datasource. whenever need connection have class:
public class jdbcutils{ private static datasource datasource; static{ datasource = new db2simpledatasource(); datasource.setdatabasename("dbname"); datasource.setservername("xxx.xxx.xxx.xxx"); datasource.setportnumber(447); datasource.setuser("user"); datasource.setpassword("pass"); datasource.setdrivertype(4); datasource.setcurrentschema("schema"); //or improve datasource through jndi lookup if defined on server } public static connection getconnection() throws sqlexception{ homecoming datasource.getconnection() } } java database servlets web-applications web
Comments
Post a Comment