Best practices for connecting to a database from a Web service

I develop Web services that need to connect to an Oracle database. Currently, I connect to the database using jdbc as this class:

con = DriverManager.getConnection (connectURL, "HR_DATA_READERS", "xxxxx").

I do not like this approach because it hardcodes the connection string and account information. One of our colleagues has suggested that we use the properties file, but this leaves the user name and password in full view. Given that we can define jdbc dataources on the server of the SOA and the server offers all the nice features like pooled connection etc, is there a way to connect to the database using the data source defined the SOA rather than defining a connection server jdbc in the Web service itself? Is the best way to do it or is there still a way paste?

Thank you

Hi, Alix,.

If you are JEE compatible environment. i.e. WLS 12 c, you can use resource injection approach, instead of manually coding the above proposed DS research.

More information on injected resources and you will find here - http://docs.oracle.com/cd/E19226-01/820-7627/6nisfjmbl/index.html

"For example, you can use this tutorial - Servlet JDBC DataSource resource Injection" Open tutorials

Take a look at sections 5.3 and 5.4 only, which is what the code should look like and how to configure resource in the web.xml file.

And always use finally to try to close the db connection, otherwise in the case of exceptions, as it is not returned to the pool and at some point he's going to get exhausted.

Hope this helps,

A.

Tags: Fusion Middleware

Similar Questions

  • Best practices for retrieving a single value from the Oracle Table

    I'm using Oracle Database 11 g Release 11.2.0.3.0.

    I would like to know the best practice to do something like that in a PL/SQL block:

    DECLARE
        v_student_id    student.student_id%TYPE;
    BEGIN
        SELECT  student_id
        INTO    v_student_id
        FROM    student
        WHERE   last_name = 'Smith'
        AND     ROWNUM = 1;
    END;

    Of course, the problem here is that when there is no success, the NO_DATA_FOUND exception is thrown, which interrupts the execution.  So, what happens if I want to continue despite the exception?

    Yes, I could create a block nested with EXCEPTION section, etc, but it seems awkward for what seems to be a very simple task.

    I've also seen this handled like this:

    DECLARE
        v_student_id    student.student_id%TYPE;
        CURSOR c_student_id IS
            SELECT  student_id
            FROM    student
            WHERE   last_name = 'Smith'
            AND     ROWNUM = 1;
    BEGIN
        OPEN c_student_id;
        FETCH c_student_id INTO v_student_id;
        IF c_student_id%NOTFOUND THEN
            DBMS_OUTPUT.PUT_LINE('not found');
        ELSE
            (do stuff)
        END IF;
        CLOSE c_student_id;   
    END;

    But it still seems to kill an Ant with a hammer.

    What is the best way?

    Thanks for any help you can give.

    Wayne

    201cbc0d-57b2-483a-89f5-cd8043d0c04b wrote:

    What happens if I want to continue despite the exception?

    It depends on what you want to do.

    You expect only 0 or 1 rank. SELECT INTO waiting for exactly 1 row. In this case, SELECT INTO may not be the best solution.

    What exactly do you do if you return 0 rows?

    If you want to set a variable with a NULL value and continue the treatment, Frank's response looks good, or else use the modular Billy approach.

    If you want to "do things" when you get a line and 'status quo' when you don't get a line, then you can consider a loop FOR:

    declare
      l_empno scott.emp.empno%type := 7789;
      l_ename scott.emp.ename%type;
    begin
      for rec in (
        select ename from scott.emp
        where empno = l_empno
        and rownum = 1
      ) loop
    l_ename := rec.ename;
        dbms_output.put_line('<' || l_ename || '>');
      end loop;
    end;
    /
    

    Note that when no line is found, there is no output at all.

    Post edited by: StewAshton - Oops! I forgot to put the result in l_ename...

  • Best practices for automation of ghettoVCBg2 starting from cron

    Hello world!

    I set up an instance of vma for scheduling backups with ghettoVCBg2 in a SIN store. Everything works like a charm from the command line, I use vi fastpass for authentication, backups complete very well.

    However, I would like to invade the cron script and got stuck. Since vifp is designed to run only command line and as I read not supposed to work from a script, it seems that the only possibility would be to create a backup user dedicated with administrator privileges and store the user and pass in the shell script. I'm not happy to do so. I searched through the forums but couldn't ' find any simple solution.

    any IDE for best practices?

    Thank you

    eliott100

    In fact, incorrect. The script relies on the fact that the host ESX or ESXi are led by vi-fastpass... but when you run the script, it does not use vifpinit command to connect. It access credentials via the modules of vi-fastpass which don't vifpinit library but as you have noticed, you cannot run this utility in off-line mode. Therefore, it can be scheduled via cron, basically, but you must run the script interactively, just set up in your crontab. Please take a look at the documentation for more information

    =========================================================================

    William Lam

    VMware vExpert 2009

    Scripts for VMware ESX/ESXi and resources at: http://engineering.ucsb.edu/~duonglt/vmware/

    Twitter: @lamw

    repository scripts vGhetto

    Introduction to the vMA (tips/tricks)

    Getting started with vSphere SDK for Perl

    VMware Code Central - Scripts/code samples for developers and administrators

    VMware developer community

    If you find this information useful, please give points to "correct" or "useful".

  • is it possible to return a figure to the database from a web service

    I have a REST web services configuration that has 4 values

    Is it possible to use a db call to enter these 4 values that can be used in an insert in the database?

    Thank you

    Yes it is available: [url http://docs.oracle.com/cd/B19306_01/appdev.102/b14258/t_dburi.htm#i1007928] 10.2 documentation packages and Types.

    You must copy my blog instead: my answer was typo with a T too much ;-)

    Edit: Fixed the URL

    Published by: Kim Berg Hansen on October 19, 2012 10:00

  • Best practices for creating a new project from an existing WebHelp

    I am currently working to WebHelp Pro (version RH is 9.0.2.271).

    I have a WebHelp project that currently supports the 2012 version of one of our projects. What I had to do was to create a separate project for 2013, using files of 2012 as a starting point. I couldn't find a way in HR to create a new project by importing an existing project of WebHelp, so I copied the files of 2012 in a new directory, open the project and renamed it.

    What drives this issue is that, as a result of this exercise, all seemed well, for once. However, I recently had to create new topics in the 2012 version. However, when I imported these subjects to the 2013 and compiled project, they disappeared - even if the htm files still appear in the appropriate folder of the file 2013 (when we look at with Windows Explorer).

    After reading a few posts on the forum, I thought I might have corrupted my database by creating the incorrectly the new project-, but if what I've done, it's the wrong way to go about this, I don't know what is the right way. I will be grateful for any suggestion.

    The easy way to do this is to create a copy using Windows Explorer.

    Open the project and click file > rename.

    Then you have your project is ready in 2013.

    See www.grainge.org for creating tips and RoboHelp

    @petergrainge

  • Best practices for the storage of information from lead

    Hi all

    I use a qualification process using a script assessment of lead. Via this script our reps ask the potential customer 8 questions and a score is calculated.

    Now, the reps will begin the process to convert leads into opportunities - in order of priority according to the script of assessment score.

    Then information that is entered in the assessment script is stored in 8 fields in the lead record and is relevant to only one service in a hospital (anesthesia fx). This information is very valuable to us in the future - because it tells us about the potential prospects for the purchase of other products.

    Now, I want to make sure that this information is passed on the most appropriate way when wires are converted into accounts, contacts, and opportunities. My first thought was to create 8 new fields in the opportunity record and communicate with the record type and map the conversion of lead to these areas. Through reflection, this would help me with a large number of redundant data. Also the data will be regularly updated - which will cause problems with this solution.

    Another option is to display the fields of 8 lead and related information on the opportunity and contact record details page. Or I could pass data to the contact record and tell officials that this is where it should be updated in the future.

    I'm pretty new to OnDemand, so I couldn't be on the right track here! Any help will be much appreciated :-)

    Kind regards
    Allan

    Allan, once the lead is converted the lead record (with your 8 domains) is available as a related under the opportunity and contact records record. This allows you to make updates to these fields without having to do several times if you match during the conversion from lead.

  • Best practices for Smartview when upgrading from Excel 2003 to Excel 2007?

    Anyone know the best practice for Smartview during the upgrade from Excel 2003 to Excel 2007?


    Current users have Microsoft Excel 2003 with Smartview 9.3.1.2.1.003.

    Computers are upgraded to Microsoft Excel 2007.


    What is the best practice for Smartview in this situation?

    1. do nothing with Smartview and just install Excel 2007.

    2. install Excel 2007 and then uninstall and reinstall Smartview

    3 uninstall Smartview, Excel 2007 installation and then install Smartview

    4 something else?


    Thank you!

    We went with option 1 and it worked very well. Be aware that OAS Treaty substantially slower in Excel 2007 to 2003. Many users have been/is unhappy about the switch. We have not tested SV v11 yet, so I don't know if it has improved performance with Excel 2007 or not (hopefully it does).

  • Best practices for SQL

    I started a discussion a few weeks there is movement .vmdks from the supplier of storage to another in regard to and got some great answers.  What I didn't ask was if the hard contain databases SQL is there special considerations when you cut storage EMC VNX (pools versus grpoups raid) or when the data store is created in vCenter.  I know that this may be more an EMC forum question but maybe someone in the world of VMware has a recommendation or can provide a link to best practices for the VNX.  Thank you.

    Post edited by: vmroyale to change the case of SQL

    Have you seen the document "using EMC VNX with VMware vSphere storage solutions"?

  • Best practices for managing strategies of path

    Hello

    I get conflicting advice on best practices for managed paths.

    We are on version 4.0 of ESXi connection to a HP EVA8000. Best practices guide HP recommends setting the strategy of railways handle on Round Robin.

    This seems to give two active paths to the optimized controller. See: http://h20195.www2.hp.com/v2/GetPDF.aspx/4AA1-2185ENW.pdf

    We used certain consultants and they say that the best practices of Vmware for this solution is to use the MRU policy which translates a single path to the optimized controller.

    So, any idea what good practice is best practice? Does make a difference?

    TIA

    Rob.

    Always go with the recommendation of the storage provider.  VMware recommendation is based on the characteristics of the generic array (controller, capable ALUA failover methods, etc.).  The storage provider's recommendation is based on their performance and compatibility testing.  You may want to review their recommendations carefully, however, to ensure that each point is what you want.

    With the 8000, I ran with Round-Robin.  This is the option of creating more robust paths available to you from a failover and performance point of view and can provide performance more even through the ports on the storage controller.

    While I did of the specific tests/validation, the last time that I looked at the docs, the configuration of HP recommends that you configure each IO to the ports in the switch configuration.  This adds the charge to the ESX host, the switch to other ports, but HP claims that their tests showed that it is the optimal configuration.  It was the only parameter I wondered in their recommendation.

    If you haven't done so already, be sure to download the HP doc on configuring ESX and EVA bays.  There are several parameters that you must configure the policy path, as well as a few scripts to help make the changes.

    Virtualization of happy!

    JP

    Please consider awarding points to useful or appropriate responses.

  • I would like to know the "best practices" for unplugging my computer permanently to the internet and other updates.

    Thank you for taking the time to read this. I would like to know the "best practices" for unplugging my computer permanently to the internet and other updates. I thought I would do a clean install of Windows XP, install my Microsoft Works again and nothing else. I would like to effectively transforming my computer into a word processor. He continues more and more slow. I get blue screen errors, once again. I received excellent Microsoft Support when it happened before, but since my computer is around 13 years, I think it is not worth the headache to try to remedy. I ran the Windows 7 Upgrade Advisor, and my computer would not be able to upgrade. Please, can someone tell me how to make it only a word processor without updates or internet connection? (I already have a new computer with Microsoft Windows 7 Home Premium, it's the computer that I use. The old computer is just sitting there and once a week or so I updates.) I appreciate your time, thank you!

    original title: old computer unstable

    http://Windows.Microsoft.com/en-us/Windows-XP/help/Setup/install-Windows-XP

    http://www.WindowsXPHome.WindowsReinstall.com/sp2installxpcdoldhdd/indexfullpage.htm

    http://aumha.NET/viewtopic.php?f=62&t=44636

    Clean install XP sites
    You can choose which site to reinstall XP.

    Once it is installed, then you do not have to connect what anyone, however, some updates may be required to perform the work, test this by installing work and see if you get an error msg. Except that you should be fine.

  • Just improved m tips on best practices for sharing files on a Server 2008 std.

    The field contains about 15 machines with two domain controllers, one's data is the app files / print etc...  I just upgraded from 2003 to 2008 and want to get advice on best practices for the establishment of a group of file sharing. Basically I want each user to have their their own records, but also a staff; folder. Since I am usually accustomed to using windows Explorer, I would like to know if these actions can be done in the best conditions. Also I noticed on 2008 there is a feature of contacts. How can it be used? I would like to message or send an email to users their file locations. Also, I want to implement an admin at a lower level to handle the actions without making them far in on the server, not sure.

    I read a certain bbut I don't like test direct more because it can cause problems. So basically a way short and neat to manage shares using the MMC, as well as the way that I approach their mail from the server of their actions. Maybe what kind of access cintrol or permissions are suitable also for documents. Also how can I have them use office templates without changing the format of the model.

    THX

    g

    Hello 996vtwin,

    Thank you for visiting the Microsoft Answers site. The question you have posted is related to Windows Server and would be better suited to the Windows Server TechNet community. Please visit the link below to find a community that will support what ask you:

    http://social.technet.Microsoft.com/forums/en-us/category/WindowsServer

    Hope this helps J

    Adam
    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think

  • What are the best practices for creating only time data types, and not the Date

    Hi gurus,

    We use 12 c DB and we have a requirement to create the column with datatype of time only, if someone please describe what are the best practices for the creation of this.

    I would strongly appreciate ideas and suggestions.

    Kind regards
    Ranjan

    Hello

    How do you intend to use the time?

    If you are going to combine with DATEs or timestamps from a other source, then an INTERVAL DAY TO SECOND or NUMBER may be better.

    Will you need to perform arithmetic operations on time, for example, increase the time to 20%, or take an average?   If so, the NUMBER would be preferable.

    You are just going to display it?  In this case, DAY INTERVAL in SECONDS, DATE or VARCHAR2 would work.

    As Blushadow said, it depends.

  • Best practices for the integration of the Master Data Management (MDM)

    I work on the integration of MDM with Eloqua and are looking for the best approach to sync data lead/Contact changes of Eloqua in our internal MDM Hub (output only). Ideally, we would like that integration practically in real time but my findings to date suggest that there is no option. Any integration will result in a kind of calendar.

    Here are the options that we had:

    1. "Exotic" CRM integration: using internal events to capture and queue in the queue changes internal (QIP) and allows access to the queue from outside Eloqua SOAP/REST API
    2. Data export: set up a Data Export that is "expected" to run on request and exteernally annex survey via the API SOAP/REST/in bulk
    3. API in bulk: changes in voting that has happened since the previous survey through the API in bulk from Eloqua outside (not sure how this is different from the previous option)

    Two other options which may not work at all and who are potentially antimodel:

    • Cloud connector: create a campaign questioning changes to schedule and configure a connector of cloud (if possible at all) to notify MDM endpoint to query contact/lead "record" of Eloqua.
    • "Native" integration CRM (crazy): fake of a native CRM endpoint (for example, Salesforce) and use internal events and external calls to Eloqua push data into our MDM

    Issues related to the:

    1. What is the best practice for this integration?
    2. Give us an option that would give us the close integration in real-time (technically asynchronous but always / event-based reminder)? (something like the outgoing in Salesforce e-mail)
    3. What limits should consider these options? (for example API daily call, size response SOAP/REST)

    If you can, I would try to talk to Informatica...

    To imitate the integrations of native type, you use the QIP and control what activities it validated by internal events as you would with a native integration.

    You will also use the cloud api connector to allow you to set up an integration CRM (or MDM) program.

    You have fields of identification is added objects contact and account in Eloqua for their respective IDs in the MDM system and keep track of the last update of MDM with a date field.

    A task scheduled outside of Eloqua would go to a certain interval and extract the QAP changes send to MDM and pull the contacts waiting to be sent in place of the cloud connector.

    It isn't really much of anything as outgoing unfortunately use Messaging.  You can send form data shall immediately submit data to Server (it would be a bit like from collections of rule of integration running of the steps in processing of forms).

    See you soon,.

    Ben

  • Best practices for network configuration of vSphere with two subnets?

    Well, then I'll set up 3 ESXi hosts connected to storage shared with two different subnets. I configured the iSCSI initiator and the iSCSI with his own default gateway - 192.168.1.1 - targets through a Cisco router and did the same with the hosts configured with its own default gateway - 192.168.2.2. I don't know if I should have a router in the middle to route traffic between two subnets since I use iSCSI ports linking and grouping of NETWORK cards. If I shouldn't use a physical router, how do I route the traffic between different subnets and use iSCSI ports binding at the same time. What are the best practices for the implementation of a network with two subnets vSphere (ESX host network: iSCSI network)? Thank you in advance.

    Install the most common iSCSI would be traffic between hosts and

    the storage is not being routed, because a router it could reduce performance.

    If you have VLAN 10(192.168.1.0/24) iSCSI, VLAN 20 (192.168.2.0/24) ESX

    MGMT and VLAN 30 (192.168.3.0/24) comments VMs and VLAN 40 (192.168.4.0/24)

    vMotion a deployment scenario might be something like:

    NIC1 - vSwitch 0 - active VMK (192.168.1.10) MGMT, vMotion VMK (192.168.4.10)

    standby

    NIC2 - vSwitch 1 - current (VLAN30) guest virtual machine port group

    NIC3 - vSwitch 2 - active VMK1 (192.168.1.10) iSCSI

    NIC4 - vSwitch 2 - active VMK2 (192.168.1.11) iSCSI

    NIC5 - vSwitch 1 - current (VLAN30) guest virtual machine port group

    NIC6 - vSwitch 0 - MGMT VMK (192.168.2.10) standby, vMotion

    VMK (192.168.4.10) active

    You would place you on VLAN 10 storage with an IP address of something like target

    192.168.1.8 and iSCSI traffic would remain on this VLAN. The default value

    gateway configured in ESXi would be the router the VLAN 20 with an ip address of

    something like 192.168.2.1. I hope that scenario help set some options.

    Tuesday, June 24, 2014 19:16, vctl [email protected]>

  • Best practices for HP DL385p G8

    Trying to find documentation for the implementation of a HP DL385p G8 for VMware Server. I would like to find a guide to best practices for this server? Been looking for but not found anything. I would like to find things are should hyperthreading turned on and so on. I use the ESXI from HP image for pilots, that all work but just want to find the settings.

    Thank you

    Hello

    you will find on this blog: BIOS settings in a VMware ESX (i) / vSphere environment. VirtualKenneth & #039; s Blog - hqVirtual | Quality rental a detailed explanation on all the BIOS settings and why you should enable or disable it.

    hope that helps.

Maybe you are looking for

  • [HP JET 7] Macrium key bootable usb omitting 7 flow HP Tablet boot

    7 HP flow is connected via an otg cable to a 4 port non powered usb hub.  The hub contains a keyboard, mouse, and usb key. The recovery media is through the Macrium Reflect (that is installed on the HP Jet 7 Tablet) on a usb key.  Media is created co

  • USB 3.0 port does not

    Hello I bought the HP Pavilion 15 - N259TX with windows 8. Today, after installinf windows 7 ultimate my USB 3.0 port stopped worki g. I even downloaded the driver from hp site. can someone give a solution for my problem. Thanks in advance.

  • How to multiply all the items in a table by a negative

    Hello I have a 1 d table, I need to multiply each element of the array in the negative.  How would I do that?

  • LOG-IN TO REMOVE THEM FROM THE SCREEN AT STARTUP

    How can I get rid of the logon to my computer screen.  I am the only person to use it and I don't want to have to go through this step every time that I reboot.  I had managed to get rid of it before, but don't know how I did it.  I want my computer

  • I can't send email using windows mail.

    I have windows vista home preium 64 edition.my ISP comcast has suggested changing the deI have windows vista home preium 64 edition.my ISP comcast proposed fault parameters tomsmtp 587 110 incoming (pop3).I get the following error message.The message