• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how 2 access specific datasource using java code as per user requirement

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 java coding as per user requirement?

kindly help.

Regards
vishy
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yes there is a way to access the JDBC datasource configured in weblogic using java code.. Suppose you have the UAT datasource as "projectUAT", then you have to code in java as :

String dataSourceName = "projectUAT";
javax.naming.Context ctx = new InitialContext();
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic