Skip to Content
author's profile photo Former Member
Former Member

Reading JDBC DataSources on J2EE engine


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


Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on 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:

    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,


    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.