A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
how 2 access specific datasource using java code as per user requirement
Joined: Sep 14, 2010
Sep 14, 2010 07:42:35
Hi WL users
we have one specific requirement like below.
we have 2 databases where one db is for uat & one for training. for each db, one datasource is available in weblogic console.
is their a way to access either of them using
coding as per user requirement?
Joined: Aug 31, 2010
Sep 14, 2010 08:34:30
yes there is a way to access the
datasource configured in weblogic using java code.. Suppose you have the UAT datasource as "projectUAT", then you have to code in java as :
dataSourceName = "projectUAT";
javax.naming.Context ctx = new
javax.sql.DataSource ds = ctx.lookup(dataSourceName);
javax.sql.Connection conn = ds.getConnection();
//you can use the connection object as you like after this.
//you need to envelope this code snippet in proper try/catch block.
subject: how 2 access specific datasource using java code as per user requirement
How to use configured datasource
Reuse of Data Source
Java and DB Design problem.
Java Desktop Applications
Dynamic Datasource invocation at runtime in JSF-EJB3-MySql application on Eclipse3.4.1-JBoss5.0.0
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014