junit - Need to resolve com.microsoft.sqlserver.jdbc.SQLServerException: Login failed for user 'sa' -
i using junit test application. in application used datasource connection database. database connection properties getting context.xml while testing junit, had written code initialize initialcontext , set database properties in datasource, while getting connection getting login failed error. don't know why happening, please let me know how resolve these issues.
# initialization had written # // create initial context system.setproperty(context.initial_context_factory, "org.apache.naming.java.javaurlcontextfactory"); system.setproperty(context.url_pkg_prefixes, "org.apache.naming"); initialcontext ic = new initialcontext(); ic.createsubcontext("java:"); ic.createsubcontext("java:comp"); ic.createsubcontext("java:comp/env"); ic.createsubcontext("java:comp/env/jdbc"); // construct datasource sqlserverconnectionpooldatasource ds = new sqlserverconnectionpooldatasource(); ds.seturl("jdbc:sqlserver://localhost:1433;databasename=database"); ds.setuser("sa"); ds.setpassword("*****"); ic.bind("java:comp/env/jdbc/devtest", ds); // code getting connection written in class context initcontext = new initialcontext(); context envcontext = (context) initcontext.lookup("java:comp/env"); datasource ds = (datasource) envcontext.lookup("jdbc/dev" + dbenv.touppercase()); connection = ds.getconnection();
issue when datasource object initial context object database connection properties there in datasource object password missing getting exeception while creating connection of database
Comments
Post a Comment