• 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

Retrieving datasource info

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

does anyone know how I can retrieve datasource information inside the code? The project I'm currently working on requires me to log the name of the data source when encountering a StaleConnection. The reason they want this is that the code is to be deployed twice, connecting to two different instances of the database.

I'm using WebSphere and WSAD 5.1
 
author
Posts: 4335
39
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you connecting to the data source in the first place, via JNDI lookup or using a JDBC connection string? If so, can't you use either of those values as the name.

Alternatively, you could call java.sql.Connection.getMetaData() which gives you the information as defined in:

http://java.sun.com/j2se/1.4.2/docs/api/java/sql/DatabaseMetaData.html
 
reply
    Bookmark Topic Watch Topic
  • New Topic