1 Reply Latest reply on Mar 25, 2005 12:21 PM by Adrian Brock

    How to access DataSource properties

    Howard Hendler Newbie

      Hello,
      Given a DataSource object, I want to retrieve certain properties such as databasename, servername, port, etc. That is, info reflected in the connection-url.

      I am using Sybase with JBoss 4.01 and the relevant portions of my sybase-ds.xml are:

      <jndi-name>sybDS</jndi-name>
      <connection-url>jdbc:sybase:Tds:IMISFS21:3010/traccimis</connection-url>
      <driver-class>com.sybase.jdbc2.jdbc.SybDriver</driver-class>

      My sybase driver is jconn2d.jar

      In my code I am getting a connection this way:

      Context objContext = new javax.naming.InitialContext();
      DataSource ds = (DataSource) objContext.lookup("java:sybDS");
      Connection con;
      con = ds.getConnection();

      It all works fine, except I do not know how to extract the various properties of the datasource object. I want to use the URL information for certain display purposes in my app.

      The basic DataSource interface does not appear to have these methods, while the SybDataSource interface does have them. Is there a way to instantiate and work with a SybDataSource instead??

      I've done a lot of searching but could not find the answer but I'm also relatively new and may well be missing some obvious concepts.

      Thanks for any input,
      Howard