Skip to Content
avatar image
Former Member

Reading JDBC DataSources on J2EE engine

Hi,

I am developing a tool that will export the SAPDB table data into XML format.

For doing the above i've configured a DataSource in J2EE engine.I can use the above created driver in my code to get all the records of particular table and i can create a XML file from that using the following code.

"DataSource ds = (DataSource) ctx.lookup("jdbc/Reviewmanagement");"

where "Reviewmanagement" is the drivername in my J2EE engine.

Now my question is , i don't want to hardcode the drivername in my code. I want to read the driver/DataSource information programatically so that the same application i can deploy/run on any J2EE directly witout doing any modifications.

So please let me know how to read the DataSources/Drivers configured on J2EE.

Thanks & Reagrds

AnilKumar

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    May 20, 2004 at 10:39 AM

    Hi AnilKumar,

    First of all, when you use the default database schema that is created during installation, you don't need to register a new DataSource. You can use the default DataSource, which you can see in the runtime screen of JDBC Connector Service in the Visual Administrator.

    You use the DataSource to get a database connection, which enables you to actually execute SQL statements to the DB. The driver is only needed to provide you with a DataSource. So, if you want to register another DataSource - let's say for Oracle DB, you will first need to register the relevant Oracle driver, and then enter it where required to register a DataSource. You can read more about that in J2EE Engine documentation under Administration Manual->Server Administration->SAP J2EE Engine Administration->Transactions and Resource Handling-> JDBC Connector Service. Here is a link to the documentation:

    http://help.sap.com/saphelp_nw04/helpdata/en/13/a3bb3eff62847ae10000000a114084/frameset.htm

    The J2EE Engine enables you to register the so-called DataSource alias, which is a name that you can use to lookup the DataSource. It is a very convenient way to handle db connectivity with aliases, because you can redirect the alias to any DataSource that you have registered in JDBC Connector Service. So, you can use any name to lookup a DataSource from your application, and re-deploy it to any new J2EE Engine instance without changing the code. The only thing you'll have to do is to register the relevant DataSource alias for the DataSource that you want to use.

    Please, read the documentation for more details on this. I think it will be also helpful for you to read the chapter "Handling DataSources" under Development Manual-> Connectivity and Interoperability -> J2EE Connector Architecture.

    I hope this helps you.

    Best regards,

    Zornitsa

    Add comment
    10|10000 characters needed characters exceeded