DataSource lookup: where to put it ?

Hi all,
I have the following question: what's the most correct method for DataSource lookup in a Session Bean? I look it up in the setSessionContext method:
DataSource ds;
public void setSessionContext(SessionContext ctx) { 
this.ctx = ctx;
ds = (javax.sql.DataSource) new InitialContext().lookup ("myPool");
do you have other suggestions? for example I have read somewhere in this forum to use static-inizializers to populate instance variables of SSB....
comments?
thanks
Francesco

hi ,
i am also facing the same problem ,
if u had sol. for it, then try to give sol. for it
but i have error as the following
i am getting a problem (Exception)when my bean trys to connect with database.
SQLException: java.sql.SQLException: Io exception: Connection refused(DESCRIPTI
ON=(TMP=)(VSNNUM=135294976)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4)))
and i am using following in resource properties file
jdbcDataSource.5.name=jdbc/TimeSpanDB
jdbcDataSource.5.url=jdbc:oracle:thin:@myserver:1521:timeDB,scott,tiger;create=true
and also i try out with following changes
jdbcDataSource.5.name=jdbc/TimeSpanDB
jdbcDataSource.5.url=jdbc:oracle:thin:@99.0.0.201:1521:timeDB,scott,tiger;create=true
but both the time it is giving same sql connection exception
waiting for ur sol.
deepal

Similar Messages

  • Using Portable datasource lookup for a java client in OC4J 10g

    Hi,
    I'm in the process of porting a standalone java client to j2ee. At the moment I have a thick java client which uses jndi to access a global datasource configured on the OC4J server (10.1.2.0.2) and it works fine.
    Using the 'Services Guide' I decided the next step was to deploy the client as a J2EE application. At the moment the j2ee application only contains the descriptors (i.e application-client.xml and orion-application-client.xml packaged under META-INF in a .jar. This is, in turn, packaged in an .ear along with application.xml (again under META-INF.)
    This is where I'm hitting problems. The following config produces a 'javax.naming.NameNotFoundException' error
    application.xml
    <application>
         <display-name>appName</display-name>
         <description>appDescription</description>
    </application>
    application-client.xml :-
    <application-client>
         <display-name>appName</display-name>
         <resource-ref>
              <res-ref-name>jdbc/MaptoTest</res-ref-name>
              <res-type>javax.sql.DataSource</res-type>
              <res-auth>Container</res-auth>
         </resource-ref>
    </application-client>
    orion-application-client.xml :-
    <orion-application-client>
         <resource-ref-mapping name="jdbc/MaptoTest" location="jdbc/Test"/>
    </orion-application-client>
    jndi.properties :-
    java.naming.factory.initial=com.evermind.server.ApplicationClientInitialContextFactory
    java.naming.provider.url=opmn:ormi://<machine>:6004:<OC4J_INSTANCE>/appName
    java.naming.security.principal=<USERNAME>
    java.naming.security.credentials=<PASSWORD>
    client.class
    ctx = new InitialContext();
    ds = (DataSource)ctx.lookup("java:comp/env/jdbc/jdbc/MaptoTest"));
    "jdbc/Test" was configured through OAS and is present in data-sources.xml (it is the ejb-location property).
    I'm running the client through Jdeveloper. I've used SJSAS previously and was use to configuring and deploying a application module through it's own tool. SJSAS also has a tool (appclient) for running the client. Is there something similar I should be using in OC4J?
    The services guide only mentions web.xml and ejb-jar for portable datasource lookup but I assume it's also possible using application-client.xml.
    It seems to me that my descriptors don't mention the j2ee application explicitly. Am I missing an entry in one of the xml descriptors. Any help would be appreciated this is driving me crazy!
    Thanks in advance for any advice.

    Hi Geoff,
    The configurations for your client.xml files look ok. Question: where did you configure the datasources.xml i.e. under j2ee/<OC4J_Name>/config or under the application-deployments/<appname>, kindly check and let us know.
    Thanks,
    Deepak

  • Sun App Sever 8.1  /  JNDI - datasource lookup problems

    I get an error when calling the ctx.lookup function. I have the datasource and the resource set up in the server OK. I can ping successfully and view the table data. I am using NetBeans 4.1 / Sun 8.1
    I have been up all night (11pm - 4:30am) trying to figure this out.
        <%
            java.sql.Connection conn = null;
            java.util.Hashtable env = new java.util.Hashtable();
            javax.naming.Context ctx ;
            javax.sql.DataSource cachedDataSource;
            try {
            env.put(javax.naming.Context.INITIAL_CONTEXT_FACTORY,  "com.sun.jndi.cosnaming.CNCtxFactory");
            ctx = new javax.naming.InitialContext();
            cachedDataSource  = (javax.sql.DataSource)ctx.lookup("jdbc/mysql"); 
            if (cachedDataSource == null)
                {out.println("<h2>The datasource is not getting set properly</h2>");
                conn = cachedDataSource.getConnection();}
            else
            { out.println("<h2>the datasource is not null and seems like it gets initialized.<h2>"); }
            } catch (javax.naming.NamingException ne) {}
              catch (java.sql.SQLException se) {}
            env = null;
            ctx = null;
            conn.close();
            conn = null;
            cachedDataSource = null;
        %>

    RTFM
    http://docs.sun.com/app/docs/doc/819-0079
    The resource lookup in the application code looks like this:
    InitialContext ic = new InitialContext();
    String dsName = "java:comp/env/jdbc/HelloDbDs";
    DataSource ds = (javax.sql.DataSource)ic.lookup(dsName);
    Connection connection = ds.getConnection();
    The resource being queried is listed in the res-ref-name element of the web.xml file as follows:
    <resource-ref>
    <description>DataSource Reference</description>
    <res-ref-name>jdbc/HelloDbDs</res-ref-name>
    <res-type>javax.sql.DataSource</res-type>
    <res-auth>Container</res-auth>
    </resource-ref>
    The resource-ref section in a Sun Java System specific deployment descriptor, for example sun-web.xml, maps the res-ref-name (the name being queried in the application code) to the JNDI name of the JDBC resource. The JNDI name is the same as the name of the JDBC resource as defined in the resource file when the resource is created.
    <resource-ref>
    <res-ref-name>jdbc/HelloDbDs</res-ref-name>
    <jndi-name>jdbc/HelloDbDataSource</jndi-name>

  • NameNotFoundException for DataSource lookup

    Hi,
    I have a requirement where i need to push message from a client code (deployed in oc4j 10.1.3) to a remote queue which is deployed on weblogic server. i have used
    Context.INITIAL_CONTEXT_FACTORY = "weblogic.jndi.WLInitialContextFactory". I could send the message to the weblogic 9.2 server queue from oc4j 10.1.3 client code. But all my datasources lookups are failing in oc4j container.
    My lookup code looks as follows : context.lookup("java:comp/env/jdbc/DB");
    If the lookup is done using "jdbc/DB" , it succeeds. But currently, context.lookup("java:comp/env/jdbc/DB"); code is available in 700 places. So it is not possible to change the code.
    Any suggestions why existing data source lookup fails if initial context is set to weblogic specific. I also closed and nullified the initialcontext object related to weblogic server after usage.
    Regards,
    Prashant

    Your code is this:
    javax.sql.DataSource ds = (javax.sql.DataSource) context2.lookup ("mydbsrc");So you're trying to find your DataSource at JNDI location "mydbsrc".
    Your configuration is this:
    <JDBCTxDataSource JNDIName="myserver" Name="mydbsrc" PoolName="MyJDBC Connection Pool" Targets="myserver" />
    So your DataSource is at JNDI location "myserver".
    Change the configuration so that your DataSource's JNDIName is "mydbsrc":
    <JDBCTxDataSource JNDIName="mydbsrc" Name="mydbsrc" PoolName="MyJDBC Connection Pool" Targets="myserver" />
    You can do this via the WebLogic console if you want.
    Hope this helps.

  • Where i Put my swing application jar file in jboss

    Hi experts...
    I develope swing application and convert it into jar file....I know jnlp deployment using tomcat..In tomcat i
    put my appcation.jar in webapps/root folder...This is not similar in jboss..I dont know where i put my applcation.jar in jboss.If any body know the idea please let me know..

    Hi
    You have to put your jar file in
    server/default/deploy
    Regards
    M Fazal Ur Rehman

  • I changed my iPhone lately but i can't restore my last backup since it keeps saying "itunes could not restore backup because the password was incorrect" but I don't know where to put the password to make it happen... Any suggestions?

    Hey guys,
    I just bought a new iPhone but i can't restore my backup files beacuse it keeps saying "itunes could not restore backup because the password was incorrect" but I really don't know where to put the password to restore it. I really have some files that are meaningful for me so I really need help. Any suggestions anyone?

    Select your iDevice in the iTunes.
    Choose the Summary screen (tab) and scroll to the bottom of the screen.
    Then un-select Encrypt iPhone backup.
    iTunes will then prompt you to “Enter the password to unlock your iPhone backup”, enter the password you set originally.

  • My computer screen keeps going blank and then going back to the box where I put my password in to start my comp. Why is this happening?

    My computer (Macbook) was working fine this am. I left it for an hour and then came back and the screen was black (always does that as the screensaver hardly ever works). I moved the mouse to wake it up and everything was normal. I went to adjust the volume and the screen went blank and the main page with the box where I put my password in when I first start my comp appeared. I put my password in and everything was normal again. I opened a window in Safari and before it loaded completely the same thing happened, the screen went blank and went back to the password box. Does anyone know why this is happening? I don't have an external hard drive or any blank flash drives so I can't back anything up right now and am afraid I'm going to lose everything. Thank you

    Sounds like hardware failure, called boot loop. Call Apple and or go on apple.com and make Genius Bar appointment to have your iphone reviewed by a Tech. Provided you iphone shows no physical or liquid damage they will take care of you, or if you have Apple Care Plus
    Genius Bar Rerservation :  http://www.apple.com/retail/geniusbar/

  • I am trying to organize a zip file with a bunch of links and files. But when I drag an image file to a folder, it always "Snaps to grid" instead of just landing where I put it.

    I am trying to organize a zip file with a bunch of links and files. But when I drag an image file to a folder, it always "Snaps to grid" instead of just landing where I put it. All of the files are going into the same zip file but I want them visually in the space that I put them and not at the bottom of the snap to grid folder location they are looking like.  I am trying to  drag and drop files in groups so that I can group them for now, but image files always do their own "sort by" when I drag them from my web pages. Links don't do it though.  I tried resetting the folder, and deleting the DS files. No luck.

    You keep asking variants on this same question. You've had replies in all your other threads. If you can't find them, go here and click where it says Activity:
    Thomas Cannon Jr.

  • Where to put javascript code?

    Hello,
    I am trying to set some columns in a list as "read-only" and is using the following code:
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById(’4_ctl00_ctl00_TextField’);
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push(“SetReadOnly()”);
    </script>
    But I am not sure where to put the code in. Should I put it in the space in Content Editor Web Part,
    or through a link to a txt file, or in "Edit HTML"? I've tried them but none works.
    Thanks a lot!
    Patrick

    You can try this:
    1) Open your Sharepoint List. Go to List edit view.
    2) On right side of Ribbon you will find "Form Web Parts" option as shown in figure.
    3) Choose your List form which you want to edit.
    4) Now you can add web part in new window.
    5) Add Content Editor Web part.
    6) In content editor web part add the path of your "txt" file in which you have written your script, for eg.
    <!DOCTYPE html>
    <html>
    <body>
    <script type=”text/javascript”>
    function SetReadOnly()
    var elements=document.getElementById('4_ctl00_ctl00_TextField');
    elements.readOnly=true;
    _spBodyOnLoadFunctionNames.push("SetReadOnly()");
    </script>
    </body>
    </html>
    I haven't tried this method so I am not sure but hope it works...:D
    ***If my post is answer for your query please mark as answer***
    ***If my answer is helpful please vote***

  • This is less a question and more of a suggestion and I am not sure where to put it..... I would like an update that would allow you to have a tone for each individual email account

    I am not sure where to put this but I would like individual tones for all my email accounts

    Wonderful suggestion.
    You can give Apple feedback here > http://www.apple.com/feedback/
    Hop that helps

  • Why are many of my toolbar bookmarks suddenly missing, & why can't I designate where to put bookmarks now? Star won't accept double-clicks anymore.

    All of a sudden yesterday I can no longer click the star twice to tell it where to put the bookmark, and even when I click it once it doesn't save the bookmark anywhere. Also many of my toolbar bookmarks are now suddenly missing. I've tried to restore bookmarks and it says it's unable to perform that function. Help!

    You can check for problems with the <b>places.sqlite</b> database file in the Firefox profile folder.
    *http://kb.mozillazine.org/Bookmarks_history_and_toolbar_buttons_not_working_-_Firefox
    *https://support.mozilla.org/kb/Bookmarks+not+saved#w_fix-the-bookmarks-file
    *Places Maintenance: https://addons.mozilla.org/firefox/addon/places-maintenance/

  • Where to put the commit in the FORALL BULK COLLECT LOOP

    Hi,
    Have the following LOOP code using FORALL and bulk collect, but didnt know where to put the
    'commit' :
    open f_viewed;
    LOOP
    fetch f_viewed bulk collect into f_viewed_rec LIMIT 2000;
    forall i in 1..f_viewed_rec.count
    insert into jwoodman.jw_job_history_112300
    values f_viewed_rec(i);
    --commit; [Can I put this 'commit' here? - Jenny]
    EXIT when f_viewed%NOTFOUND;
    END LOOP;
    commit;
    Thanks,
    - Jenny

    mc**** wrote:
    Bulk collect normally used with large data sets. If you have less dataset such as 1000-2000 records then you canot get such a performance improvent using bulk collect.(Please see oracle documents for this)
    When you update records Oracle acquire exclusive lock for that. So if you use commit inside the loop then it will process number of records defined by limit parameter at ones and then commit those changes.
    That will release all locks acquired by Oracle and also teh memory used to keep those uncommited transactions.
    If you use commit outside the loop,
    Just assume that you insert 100,000 records, all those records will store in oracle memory and it will affect all other users performance as well.
    Further more if you update 100,000 records then it will hold exclusive lock for all 100,000 records addtion to the usage of the oracle memory.
    I am using this for telco application which we process over 30 million complex records (one row has 234 columns).
    When we work with large data sets we do not depends with the oracle basic rollback function. because when you keep records without commit itb uses oracle memory and badly slowdown all other processes.Hi mc****,
    What a load of dangerous and inaccurate rubbish to be telling a new Oracle developer. Commit processing should be driven by the logical unit of a transaction. This should hold true whether that transaction involves a few rows or millions. If, and only if, the transaction is so large that it affects the size constraints of the database resources, in particular, rollback or redo space, then you can consider breaking that transaction up to smaller transactions.
    Why is frequent committing undesirable I hear you ask?
    First of all it is hugely wasteful of rollback or redo space. This is because while the database is capable of locking at a row level, redo is written at a block level, which means that if you update, delete or insert a million rows and commit after each individual statement, then that is a million blocks that need to go into redo. As many of these rows will be in the same block, if you instead do these as one transaction, then the same block in redo can be transacted upon, making the operation more efficient. True, locks will be held for longer, but if this is new data being done in batches then users will rarely be inconvenienced. If locking is a problem then I would suggest that you should be looking at how you are doing your processing.
    Secondly, committing brings into play one of the major serialization points in the database, log sync. When a transaction is committed, the log buffer needs to be written to disc. This occurs serially for multiple commits. Each commit has to wait until the commit before has completed. This becomes even more of a bottleneck if you are using Data Guard in SYNC mode, as the commit cycle does not complete until the remote log is notified as written.
    This then brings us two rules of thumb that will always lead a developer in the right direction.
    1. Commit as infrequently as possible, usually at the logical unit of a transaction
    2. When building transactions, first of all seek to do it using straight SQL (CTAS, insert select, update where etc). If this can't be easily achieved, then use PL/SQL bulk operations.
    Regards
    Andre

  • JSP--where to put my client keystore?

    I have my webservice working. I also have my java client working. Now i'm trying
    to create a web client using JSP to access the web service. This will need the
    message-based security. The java client works fine because I can specify the directory
    of the keystore. But I don't know where to put the keystore in my JSP client.
    Anybody has some suggestions? BTW i'm using tomcat 4.1.
    many thanks.

    Hi,
    Here's a pointer to the doc on how to setup a keystore using WLS 8.1
    http://e-docs.bea.com/wls/docs81/webserv/security.html
    For Tomcat, I don't know...
    Bruce
    BTW, you might take a quick look at this, it may be of some value.
    http://dev2dev.bea.com/resourcelibrary/whitepapers/whitepaper_tomcat_migration.jsp
    Yan wrote:
    >
    I have my webservice working. I also have my java client working. Now i'm trying
    to create a web client using JSP to access the web service. This will need the
    message-based security. The java client works fine because I can specify the directory
    of the keystore. But I don't know where to put the keystore in my JSP client.
    Anybody has some suggestions? BTW i'm using tomcat 4.1.
    many thanks.

  • 10g UIX Where to put ResourceBundle?

    I'm looking at putting all my Strings in a ResourceBundle for my UIX pages. I've read the documentation for Internationalization, but I think the piece that I'm missing is where to put the properties file. Say I've got a file called 'strings.properties', and my provider looks like this:
    <provider>
         <data name="bundle" >
              <bundle class="strings.properties" />
         </data>
    </provider>Then where in the JDev project do I need to have the file in order for it to get deployed properly and found by the UIX framework at runtime?
    Also, just to be sure I'm not going crazy, I know that the documentation and even the bundle tag say to specify a Class, and I just noticed that the ResourceBundle javadoc also says that the 'baseName' parameter to the static 'getBundle' method should be a 'fully qualified class name', but I've always just given it a filename of a properties file before. So I'm assuming that the 'class' parameter to the bundle tag can be a properties filename -- is this correct?

    Whoops! Of course, the argument to the bundle class attribute should just be 'strings'.
    After some experimentation, I discovered that if I put the properties file at the root of the 'src' directory in my JDev project, then it gets transferred to the 'classes' output directory when I compile. This works for running my project in the Embedded OC4J. I haven't tried deploying it to any other app server yet. Is this the right place?

  • JUnit, where to put my unit test

    Hi all,
    I have a question regarding unit test.
    I am working on a project which has multiple packages. I need to unit test every package using JUnit. One question I have is where to put my unit test. The options are:
    1. Write unit test as a separate package. This makes the code clear but only the public functions get tested or I have to make all functions public.
    2. Write unit test in the same package of the code to be tested. This makes writing test easier but putting test and code together makes the structure dirty.
    Please let me know your opinion and tell me how do you normally do this?
    Many thanks,
    Regards,
    Kevin

    It sounds like you're probably a beginner, so this might be overkill, but here goes anyway: You might want to investigate Maven, which defines a standard directory structure that includes a test tree separate from the production tree, but yet still in the same overall folder. The beauty of this design is that you can keep both production & test code together in source control, IDE projects, etc. but they don't interfere with each other.
    Even if you don't use Maven now, you might want to consider using their standard directory structure, as it is has stood the test of time, & would facilitate using Maven if you ever decide to in the future.

Maybe you are looking for

  • IPhoto synching to iphone no longer works

    I upgraded to IOS5 and the new iPhoto update but now my phone does not synch to iPhoto. Does it have something to do with iCloud?  1.  My iCloud is not activated because the Apple ID in iCloud is wrong.  Instead they have an email alias in there but

  • IDOC: Error in ALE Service

    Hi All, I have created a new outbound idoc type ZSLSRPT and assigned it to a partner profile with type LI in we20. I tried running my customized program for idoc outbound and the status shows<b> Error in ALE Service, Entry in outbound table not found

  • XI message mapping issue

    Hi, I have HTML -> XI -> RFC scenario and I have a problem with maping ... HTML outbound interface looks like: s_element_1 s_element_2 s_element_3    s_element_3_1    s_element_3_2       s_element_3_2_1       s_element_3_2_2       s_element_3_2_3 RFC

  • Any method to Import & Export to Excel from Client Side

    Hi, Is there any method to Import and Export to Excel from the Client side. I have one procedure to export to Excel , but the excel file will be opened in the Application Server only, even if it executed from the client side. Also this procedure will

  • I can't open the Mac app downloaded from App Store

    Hi, first of all excuse me for my "rusty" english. Few days ago I purchased form App Store a game by Alawar (Brink of Consciousness - The Lonely Hearts Murders-Collector's Edition). However, after the dowload (the game exists in my applications folde