Can JNDI store a datasource? It is supposed to...

I am trying to learn how to use JNDI to store a datasource.
If I use the DataSource as below (without JNDI), the path and process works:
connection = mysqlDataSource.getConnection();However, I want to try to retrieve the connection via a Context,
and am unsuccessful in creating the initial association, like this:
MysqlDataSource dataSource = new MysqlDataSource();
dataSource.setUrl( "jdbc:mysql://127.0.0.1:3306/test" );
dataSource.setUser( stringUser );
dataSource.setPassword( stringPass );
String stringDataSourceMYS = "com.mysql.jdbc.jdbc2.optional.MysqlDataSource";
Properties properties = new Properties();
properties.put( Context.INITIAL_CONTEXT_FACTORY, stringDataSourceMYS );
properties.put( Context.PROVIDER_URL , "jdbc:mysql://127.0.0.1:3306/test" );
Context context = new InitialContext( properties );
context.bind( "jdbc/mySql" , dataSource );It renders the following error:
javax.naming.NoInitialContextException:
Cannot instantiate class: com.mysql.jdbc.jdbc2.optional.MysqlDataSource
[Root exception is java.lang.ClassCastException]This follows the example in the JDBC optional doc, but does not work.
I do not think this is a path issue (since it works w/o using the context bind).
I do not know what I need to make it "bind" properly.
Can anyone help with this? Thank You.

Context.PROVIDER_URL is the url of the JNDI provider url not the jdbc connection string.
Context.INITIAL_CONTEXT_FACTORY is the initial context factory class name not the jdbc driver class name.
Take a look at the jndi examples for your application server!
If you are running inside the app server you probobally just need to use
Context context = new InitialContext();

Similar Messages

  • How can i store the data from the list to MS-Access?

    Hi all,
    We all know that from alv it is possible to export data to Ms-excel or word or text file. Can anyone tell me how can i store the data from alv or reports to Ms-Access?
    Thanks in Advance,
    Abhijit

    Hi,
    If you want that without code, i suppose there is a option in MS-Access to import data from Excel, so you have to first export to excel and then import to Access.
    If you want to code it yourself then have a look at FM TABLE_EXPORT_TO_MSACCESS, as said in Exporting Data from R/3 to MS ACCESS
    You can also see the search results in SCN for [export data to MS-Access (45 Results)|https://www.sdn.sap.com/irj/sdn/advancedsearch?query=exportdatato+MS-Access&cat=sdn_all].
    Regards
    Karthik D

  • Can we store day wise Inventory in DSO or cube

    Hi,
    Can we store day wise inventory in DSO or in Cube using 2LIS_03_BF. Is there any standard infocube or dso is available for storing the day wise inventory.
    As far as my knowledge is concern we cannot store inventory (correct me if i m wrong).
    We have a requirement where day wise inventory needs to be stored.
    I know about 0IC_C03 and 0CM_DS03, both of these gives quantity on query run time. I want the same to be store in modelling level.
    Is it possible?
    Thanks in advance.
    Regards
    Manna Das

    Hi Manna,
    The Cube 0IC_C03 will provide all your requirments at the report level.
    But as you need that at modeling level with only specfic requirments, so either you go for generic datasource extraction or do some calculation in ABAP at the transformation level.
    Balaram

  • Caching of JNDI lookup'ed DataSources???

    What is the recommened pratice, using bean-managed Entity Beans, in regards to
    looking up the DataSource object from the JNDI tree?
    Is the best way to store the DataSource object in the session context when setEntityContext
    is called and release it on unsetEntityContext?
    or
    is it best if we lookup the DataSource object in every method and returns it back
    to the pool at the end of the same method? Like in the PETStore example from SUN.
    In a article from SUN "Seven Rules for Optimizing Entity Beans" they recommend
    to cache even DataSource objects. What is BEA's recommendation on this?
    http://developer.java.sun.com/developer/technicalArticles/ebeans/sevenrules
    Regards,
    Steen
    http://developer.java.sun.com/developer/technicalArticles/ebeans/sevenrules/

    I recommend doing the JNDI look-up in the setEntityContext method and
    storing the DataSource in a member variable.
    You should get the JDBC connection from the DataSource in each method
    and return it in each method.
    -- Rob
    Steen Laursen wrote:
    >
    What is the recommened pratice, using bean-managed Entity Beans, in regards to
    looking up the DataSource object from the JNDI tree?
    Is the best way to store the DataSource object in the session context when setEntityContext
    is called and release it on unsetEntityContext?
    or
    is it best if we lookup the DataSource object in every method and returns it back
    to the pool at the end of the same method? Like in the PETStore example from SUN.
    In a article from SUN "Seven Rules for Optimizing Entity Beans" they recommend
    to cache even DataSource objects. What is BEA's recommendation on this?
    http://developer.java.sun.com/developer/technicalArticles/ebeans/sevenrules
    Regards,
    Steen
    http://developer.java.sun.com/developer/technicalArticles/ebeans/sevenrules/
    AVAILABLE NOW!: Building J2EE Applications & BEA WebLogic Server
    by Michael Girdley, Rob Woollen, and Sandra Emerson
    http://learnWebLogic.com

  • Whenever I select iTunes It shows that it cannot open iTunes Store . What am I supposed to do for that ? Please help .

    Whenever I select iTunes It shows that it cannot open iTunes Store . What am I supposed to do for that ? Please help .

    Saw this on another post.
    Applecare Senior Advisor Txx Bxxx (I have his contact info in an email he just sent) just confirmed with me that the problem people are having with the App Store not loading is an apple issue with there servers, ITS NOT YOUR IPAD so don't go restoring it!   It's not happening to everyone however but they are looking into it, its really hit or miss.
    In the meantime ...........
    The Complete Guide to Using the iTunes Store
    http://www.ilounge.com/index.php/articles/comments/the-complete-guide-to-using-t he-itunes-store/
    Can't connect to the iTunes Store
    http://support.apple.com/kb/TS1368
    iTunes: Advanced iTunes Store troubleshooting
    http://support.apple.com/kb/TS3297
    Best Fixes for ‘Cannot Connect to iTunes Store’ Errors
    http://ipadinsight.com/ipad-tips-tricks/best-fixes-for-cannot-connect-to-itunes- store-errors/
    Try this first - Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    This works for some users. Not sure why.
    Go to Settings>General>Date and Time> Set Automatically>Off. Set the date ahead by about a year.Then see if you can connect to the store.
     Cheers, Tom

  • I can't find an app that has supposedly been downloaded

    I can't find an app that has supposedly been downloaded

    I have the same problem w a 3 g s. I did a search but no results. When I go to the app store and try to download it tells me it is installed. I would like to correct the problem as it is my banking app.

  • I currently have OS X Leopard on a macbook. No where in the entire currently that I live stocks Snow Leopard in order to upgrade. So can anyone tell me how I am supposed to upgrade to Lion without access to Snow Leopard?  arrrrgg! Thanks

    I currently have OS X Leopard on a macbook. No where in the entire country that I live stocks Snow Leopard in order to upgrade. So can anyone tell me how I am supposed to upgrade to Lion without access to Snow Leopard first?  arrrrgg! Thanks

    If by "posted to you" you mean shipped, yes. Usually UPS or FedEx is used by Apple. Note that you may need to access the Online Store that's for your country. If you are not in the US then you cannot purchase it for shipment outside of the US. You can use this link to find the store that serves your country: Change Country. You will find it at the bottom of the Online Store page.

  • Portal Database -- What it is? Can we store data in Portal itself?

    Hi Experts,
    Can you please let me know what is portal database?
    Can I store some information like Emp No and Tel No in Portal itself?
    Regards,
    Gaurav

    Hi Gaurav,
    1.Portal Database holds the portal related data like iviews,worksets,pages, roles etc.
    Refer to [How the Portal Works|http://help.sap.com/saphelp_nw04s/helpdata/en/42/BFA145731B1D64E10000000A1553F6/content.htm]
    2. Emp No and Tel No are generally for the users, so it depends on how you configure your UME.
    http://help.sap.com/saphelp_nw04/helpdata/en/da/9cd53f779c4e21e10000000a1550b0/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/7e/a2d475e5384335a2b1b2d80e1a3a20/frameset.htm
    Also refer to SAP Note 780679
                         SAP Note 718383
    Good Luck!
    Sandeep Tudumu

  • How can i store data in term of a tree structure

    how can i store data in term of a tree structure

    What a tree is the question. If you just want a fast access, ehats about Hashtable or dictionary classes ? The data there is structured in a tree. For a simple binary tree, you can use something like
    class Node {
    Node(Object data){
       Node left;
       Node right;
       Object data = data;
    void insert(Object data, Node parent){
      int test = data.compareTo(parent.data);
      if(test < 0 ){
        if(parent.left == null){
          parent.left = new Node(data);
        else{
          insert(data, parent.left);
      else{
        if(parent.right == null){
          parent.right = new Node(data);
        else{
          insert(data,parent.right);
    }And so build up a binary tree. The traversing methods can be found in almost any good book (pre-order, post-order, in-order), for search you have just to look at greater/smaller and descend in the tree.
    The Object data can be changed to what you want for storage, String, or primitive Numbers, Vectors ...
    Is that what you search for?

  • Can i store my music on my device without using my data in my phone plan streaming from the cloud? How do i put what I want on there without waiting for each song to download from the cloud one at a time?

    How can I store the music I listen to on my iphone without streaming it from the cloud and using all my data on my phone plans?  How do I dump it on my phone all at once in itunes rather than waiting for each song to download individually from the cloud?

    What??  You asked how to get all your music on your phone at once rather than downloading it to your phone from iCloud.
    Go to your purchased list in iTunes and download all your music to your iTunes library, as explained in the linked article.  Then sync it all to your phone using iTunes you're done.  The music will be stored locally on your phone and you won't have to download it again in the future.

  • How can I store my iTunes library on an NAS (Fritz Box)?

    How can I store my iTunes library on an NAS (Fritz Box)?

    1. Drag the library to the external drive, launch iTunes with the Option key held down, click on Choose Library, and point it there.
    2. Get a second. Having the backups on the same drive as the original data won't help when that drive fails.
    (66929)

  • Can I store an iPhoto library on Time Capsule?

    I would like to store my iPhoto library externally. Can I store it on my Time Capsule or do I need an additional, external hard drive?

    I would like to store my iPhoto library externally. Can I store it on my Time Capsule
    Please do NOT do this.
    Access to the library will be very slow, even more so if you are using wireless. More importantly, there is a real danger that any break in communication between iPhoto and the iPhoto library will create a corruption issue that will likely affect the entire library, rendering it useless. Confirm with the experts in the iPhoto support area about this to verify.
    iPhoto
    In addition, if you move the iPhoto library to the Time Capsule......have you thought about how you will back up the iPhoto library that is on the Time Capsule? Obviously, you will still need another hard drive to backup the "original" iPhoto library on the Time Capsule.
    A much better plan would be to connect a USB or FireWire drive directly to your Mac.....and move the iPhoto library to that hard drive. Access to the library will be fast....just as if the library was on your Mac's hard drive.
    Then.....Time Machine can be set up to back up both your Mac and the hard drive to the Time Capsule.  That would be a minimum backup plan. Many of us who value our images make additional copies of the library on yet another hard drive on a regular basis.

  • I can not store all my Music on my internal Macbook pro hard drive so I am storing it on a large external drive connected to my airport extrem.  How do I get Itunes to search for the music here with out trying to copy it to my laptops hard drive??

    I can not store all my Music on my internal Macbook pro hard drive so I am storing it on a large external drive connected to my airport extreme (2 TB drive plugged into the USB port).  I see the drive on my laptop and I can add and delete files no problem.  How do I get Itunes to search for the music here with out trying to copy it to my laptop's hard drive?  I don't have enough space to do that.

    How did you move the music to the external drive?  What exactly is on the drive?  The entire iTunes folder or only music?  If it is the entire iTunes folder you can do the option+start suggestion earlier.  If you copied only music and did so by dragging it there then you need to delete it again and consolidate/organize it there instead so iTunes tracks the move.  iTunes 12 for Mac: Change where your iTunes files are stored - http://support.apple.com/kb/PH19507

  • Can I store multiple bootable images in the same partition?

    Can I store multiple bootable images in the same partition or do they each need their own partition? I am going to use disk utility to create a copy of my current OSX 10.5 system on a new external drive before upgrading to Snow Leopard. Then I want to create a bootable copy of Snow Leopard. Can I create one partion large enoough to hold both images or will I need to create a separate partition for each. I have done booting off of an external hard drive and it works well. I do not know how the system sees this and thus if I store both images on the same partition, will it give me both as a boot option at startup or will it see only one?

    They will need separate partitions to be bootable

  • How can I store received email in a folder on my iPad *

    How can I store received email in a folder on my iPad *
    I am trying to save certain messages on my iPad but don't know how to make a folder with email!

    You can only add folders to the email account if it is an IMAP account. If you see an EDIT button at the top of the window when you are in the email account - where you can see your inbox, sent and trash folders - if there is an edit button at the top of that window - you can tap that and then an Add Mailbox option appears at the bottom of the window.
    If you do not see that edit button, you do not have an IMAP account and you cannot add folders.

Maybe you are looking for