Please Help - To keep LDAP connection alive

Hi,
I have used the below function to communicate with LDAP which I have taken and modified from one of the posts in this forum.
My issue is, each time the function opens a connection, search and closing the connection and its seriously affects the performance.
I hope we can resolve this by keeping the connection alive. As I am new to this concept, I am not sure how to do this.
It would be great, if some one help me to keep the connection alive for the below function. Thanks in advance.
create or replace FUNCTION <name> (loginname VARCHAR2)
RETURN NUMBER
IS
-- Adjust as necessary.
l_ldap_host VARCHAR2(256) := '';
l_ldap_port VARCHAR2(256) := '';
l_ldap_user VARCHAR2(256) := '';
l_ldap_passwd VARCHAR2(256) := '';
l_ldap_base VARCHAR2(256) := '';
l_retval PLS_INTEGER;
l_session DBMS_LDAP.session;
l_attrs DBMS_LDAP.string_collection;
l_message DBMS_LDAP.message;
l_filter varchar2(35):='xxxx='|| loginname;
l_count NUMBER:=0;
BEGIN
-- Choose to raise exceptions.
DBMS_LDAP.USE_EXCEPTION := TRUE;
-- Connect to the LDAP server.
l_session := DBMS_LDAP.init(hostname => l_ldap_host,portnum => l_ldap_port);
l_retval := DBMS_LDAP.simple_bind_s(ld => l_session,dn => l_ldap_user,passwd => l_ldap_passwd);
-- Get attribute
l_attrs(1) := 'xxxx';
l_retval := DBMS_LDAP.search_s(ld => l_session, base => l_ldap_base, scope => DBMS_LDAP.SCOPE_SUBTREE, filter => l_filter, attrs => l_attrs, attronly => 0, res => l_message);
l_count:=DBMS_LDAP.count_entries(ld => l_session, msg => l_message);
-- Disconnect from the LDAP server
l_retval := DBMS_LDAP.unbind_s(ld => l_session);
return l_count;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('Error :'||SQLERRM);
return 0;
END <fun name>;
Thanks,
Praveen
Edited by: 920577 on Mar 13, 2012 9:40 AM
Edited by: 920577 on Mar 13, 2012 9:41 AM

The basic template looks as follows:
SQL> create or replace package Foo as
  2 
  3  procedure LdapLogoff;
  4  function GetData( empName varchar2 )  return number;
  5 
  6  end;
  7  /
Package created.
SQL>
SQL> create or replace package body Foo as
  2 
  3  isLoggedOn boolean;
  4 
  5  procedure LdapLogon is
  6  begin
  7          DBMS_OUTPUT.put_line( '..running logon()' );
  8          isLoggedOn := true;
  9  end;
10 
11  procedure LdapLogoff is
12  begin
13          DBMS_OUTPUT.put_line( '..running logoff()' );
14          isLoggedOn := false;
15  end;
16 
17  function GetData( empName varchar2 ) return number is
18  begin
19          if not isLoggedOn then
20                  LdapLogon();
21          end if;
22         
23          DBMS_OUTPUT.put_line( '..running GetData() for '||empName );
24          return(
25                  round(DBMS_RANDOM.Value(1,100))
26          );
27  end;
28 
29 
30  --// main()
31  begin
32          DBMS_OUTPUT.put_line( 'Package Foo loaded into memory' );
33          isLoggedOn := false;
34  end;
35  /
Package body created.
SQL>
SQL>
SQL> select empno, ename, Foo.GetData(ename) as ID from emp order by empno;
     EMPNO ENAME              ID
      7369 SMITH              23
      7499 ALLEN              47
      7521 WARD               88
      7566 JONES              71
      7654 MARTIN             91
      7698 BLAKE              28
      7782 CLARK              92
      7788 SCOTT              91
      7839 KING               48
      7844 TURNER             89
      7876 ADAMS              64
      7900 JAMES              16
      7902 FORD               18
      7934 MILLER             35
14 rows selected.
Package Foo loaded into memory
..running logon()
..running GetData() for SMITH
..running GetData() for ALLEN
..running GetData() for WARD
..running GetData() for JONES
..running GetData() for MARTIN
..running GetData() for BLAKE
..running GetData() for CLARK
..running GetData() for SCOTT
..running GetData() for KING
..running GetData() for TURNER
..running GetData() for ADAMS
..running GetData() for JAMES
..running GetData() for FORD
..running GetData() for MILLER
SQL>
SQL> select empno, ename, Foo.GetData(ename) as ID from emp where rownum = 1;
     EMPNO ENAME              ID
      7369 SMITH               9
..running GetData() for SMITH
SQL>
// call Foo.Logoff manually when done, or leave it to
// Oracle to close and release resources when the
// session terminates

Similar Messages

  • ADK - Keeping EIS Connections Alive

    Hi,
              I am using the ADK that comes with WL 8.1 SP3. The challenge I am facing is to keep my connections alive while there is no activity (at the TCP/IP socket level) between the app server and the EIS.
              The EIS closes any sockets after 30 minutes of inactivity causing the connections to go into CLOSE_WAIT state.
              Is there any method I can use within the connector to keep pinging the server and make sure these connections have TCP/IP traffic?
              Has anyone used the <test-frequency-seconds> weblogic-ra.xml? What is its purpose? pinging?
              Appreciate your insight..

    Hi
              I have a requirement, which is some what similar to what is mentioned above.
              I too have to ping the interface at regular intervals to keep the connection alive. I also assumed that, we can use the test-frequency-seconds attribute. But for that to work, we have to implement the interface, http://java.sun.com/j2ee/1.4/docs/api/javax/resource/spi/ValidatingManagedConnectionFactory.html, which is there only from weblogic 9.
              But since our client is using weblogic 8.1, we are tied to that version.
              Can anyone please assist in solving this.

  • Please help, I can't connect to iTunes store on ipad2

    Please help, I keep trying to download apps on my ipad2 and for a week my iPad keeps saying can't connect to iTunes store. I have tried restarting the ipad, turning the wifi on and off, logging in and out, and am ready to get rid of this thing!!

    Check your appleID and your billing name in your iTunes account. Make sure you are not using the & (ampersand) symbol anywhere.  If you are, edit to remove the & symbol, save and log out/in.

  • I am a OS10.7.4 user. yesterday i bought a Lacie external hard disk but error message appear said " You cant open the applicant LaCie setup assistant because PowerPC applicants are no longer support". please help me how to connect my mac with Lacie??

    i am a OS10.7.4 user. yesterday i bought a Lacie external hard disk but error message appear said " You cant open the applicant LaCie setup assistant because PowerPC applicants are no longer support". please help me how to connect my mac with Lacie??

    You do not need the Setup Assistant; in fact, you do not need any software on an external hard drive. I have two LaCie's; I erased the drive as soon as I plugged it in. You will need to format it anyway because most hard drives come Windows formatted. So, if you only want to use it with the Mac, highlight it in Disk Utility and choose Mac OS Extended (Journaled) as the format and the GUID Partition scheme under Options. While doing that, it will erase the drive (and get rid of the LaCie software) - once finished, your drive is ready to use for Time Machine or any other backup plans you have for it.

  • Please help me, How to connect my printer Canon pixma MP160 to my mac OS X Yosemite?

    please help me, How to connect my printer Canon pixma MP160 to my mac OS X Yosemite?

    You do not need the Setup Assistant; in fact, you do not need any software on an external hard drive. I have two LaCie's; I erased the drive as soon as I plugged it in. You will need to format it anyway because most hard drives come Windows formatted. So, if you only want to use it with the Mac, highlight it in Disk Utility and choose Mac OS Extended (Journaled) as the format and the GUID Partition scheme under Options. While doing that, it will erase the drive (and get rid of the LaCie software) - once finished, your drive is ready to use for Time Machine or any other backup plans you have for it.

  • Please help.  Keep getting a conversion error when trying to convert a PDF to a .docx. Advice?

    Please help.  Keep getting a conversion error when trying to convert a PDF to a .docx. Advice?

    Sara,
    Please see my answers in bold below.
    What browser are you using? Try clearing the cache, or using a different browser. N/A
    Are you converting from within Reader, or directly via the ExportPDF website. Within Reader.I disabled the OCR and this did not work either. Try converting from within Reader, and disable OCR as detailed in this document: How to disable Optical Character Recognition (OCR) when converting PDF to Word or Excel.
    Are you on a networked computer? Make sure that there aren't any firewall/proxy settings that are preventing you from uploading files to the Internet. Not having problems uploading the file--that works fine.
    Make sure the file is within the file-size limit of 100 MB. It is <40.
    I get the error message, "File failed to be converted using Adobe ExportPDF online."
    Thanks for your help in advance.

  • Hello, please help, my interface is connected to the microphone and when i open Logic 9 it does´t work. But I opened garageband to check and it works fine. I can record voice with any effect... With Logic i see the sound passes in the interface.

    Hello, please help, my interface is connected to the microphone and when i open Logic 9 it does´t work. But I opened garageband to check and it works fine. I can record voice with any effect... With Logic i see the sound passes in the interface but does not arrive in Logic. The Loops works fine and i can hear. Is just the sound to record the voice it does not work. What can i do ??? I used Logic before in the same computer and it worked fine. Thank you so much, I´m a begginer recording myself.

    Make sure you go into preferences in Logic and set the audio input to be your interface and the audio output to be either built in output or the interface, if that is hooked up to something else. It sounds like Garageband has the audio interface set as the input but not Logic.
    Also make sure you close all other applications except Logic to ensure it is not running in slave mode...

  • Keep wifi connection alive

    Hi. I've noticed that after moving from opensuse to arch, my wifi connection dies on me after inactivity. I've tried this workaround:
    * Add a crontab to ping a website every 15 minutes. I'm using this command:
    * ping -c 4 www.google.com
    However, the connection still dies. Is there a better way to keep my connection alive? Perhaps if I increase the number of packets?

    As per this ubuntu forum post, I found something that might do the trick
    http://ubuntuforums.org/showthread.php?t=420959
    Adapted to arch, this may work:
    #!/bin/sh
    HOST=www.google.com
    ping -c 1 -W 10 $HOST &>/dev/null
    if [ $? -eq 0 ]; then
    #ping is ok
    exit
    else
    #first try
    ifconfig wlan0 down
    sleep 3
    ifconfig wlan0 up
    sleep 10
    ping -c 1 -W 10 $HOST &>/dev/null
    if [ $? -eq 0 ]; then
    exit
    else
    #second try
    /etc/rc.d/wlan restart
    /etc/rc.d/network restart
    iwconfig wlan0 essid NOAH_S_ARK
    sleep 10
    ping -c 1 -W 10 $HOST &>/dev/null
    fi
    fi
    The corresponding root crontab entry to run it every 20 minutes is
    */20 * * * * <nameofscript>
    Gonna try when I get home.

  • How to keep the connection alive?

    Hello! Happy new year!
    I have to write an HTTP server that comunicates with many clients in the same time,but keeps the connection with a client open if there the corresponding header is Keep-Alive. I have used threads,and I've tested my program in the following way: I've requested the one page of the site and then I've followed a link from that page. I expected that the broowser and the server talk to the same thread every time,but it seems that they don't. The code I've written is:
    //HTTPServer class
    ServerSocket serverSocket = null;
            boolean listening = true;
            try {
                serverSocket = new ServerSocket(80);
            } catch (IOException e) {
                System.err.println("Could not listen on port: 80.");
                System.exit(-1);
            while (listening)
                  new HTTPMultiServerThread(serverSocket.accept()).start();
    //HTTPMultiServerThread
    public void run() {
         //     System.out.println(socket.toString());
              try {
    while(!serverSocket.isClosed())){
                  DataOutputStream out = new DataOutputStream(socket.getOutputStream());
                  DataInputStream in = new DataInputStream( socket.getInputStream());
                  int nrBytes = in.available();
                  if(nrBytes > 0){
                       byte[] bytes = new byte[nrBytes];
                       in.read(bytes);
                       System.out.println("Procesez mesajul:" + nrBytes + new String(bytes));
                       HTTPMessage processedMess = new HTTPMessage(bytes).processMessage();
                       System.out.println("Inchid conexiunea.");
                        log("log.txt", new HTTPMessage(bytes).getStatusLine() + " " + new Data().getCurrentTime());
                   //send the message   
    out.write(processedMess.getBytes(),0,processedMess.getBytes().length);
                       /* inchid conexiunea
                  else{
                       String ret = new String("HTTP/1.1 500 Internal Server Error\n");
                        ret += "Host: cristi\n";
                      ret += "Date: " + new Data().getCurrentTime()+"\r\n";
                      ret += "\r\n";
                      ret += "<html><body><p>HTTP/1.1  500 Internal Serve Error</p> </body><html>\r\n";
                      out.write(ret.getBytes());
                  out.close();
                  in.close();
                       if(new HTTPMessage(bytes).getHeaderValue("Connection").equals("Close"))
                  socket.close();
         }//end while
              } catch (IOException e) {
                  e.printStackTrace();
        }I would also like to know how many clients are waiting to be served,in order to develop statistics about the server response time. 10X

    hi
    same to u .
    i think what i get from ur code that ....
    use some vector at the server side and whenever any client is connected (offcourse first time or not (depend on u !!)) create an object corresponding(generally created by server for every client) ..
    save this in the vector .. and pass it the size of vector to the client with the response .
    may this help u .
    regards
    akash
    Indiagames Ltd
    [email protected]
    India

  • PLEASE HELP MAIL KEEPS CRASHING!!!!

    For some reason my mail keeps crashing. Whenever I try to do anything with my junk mail, the program crashes. If I mark an email as junk it crashes. If I try to move an email out of my junk mail it crashes. Can someone please please please help me out? I've tried to reset my junk mail settings and it still crashes....
    Thanks
    Joe

    Are you really using Mac OS X 10.4.2, as your profile indicates?
    There is probably some corruption in one or more of the files used by the junk filter. The following procedure thoroughly gets rid of all those files, so that Mail creates them anew:
    1. Quit Mail if it's running.
    2. In the Finder, go to ~/Library/Mail/.
    3. Locate LSMMap2 and move it to the Trash. This file stores information about what does and doesn't constitute junk, and is what allows the junk filter to learn. Clicking the Reset button in Preferences > Junk Mail also deletes LSMMap2. The file was called just LSMMap in early versions of Mail, delete that as well if you see it.
    4. Locate DefaultCounts and move it to the Trash. This file keeps statistics about the number of messages that have been marked as junk, either automatically by the junk filter or manually by the user.
    5. Locate MessageRules.plist and move it to the Desktop. This is where Mail 2.x stores all rules, including those used by the junk filter. If there is a file called MessageRules.plist.backup, move it to the Desktop too. You may also see MessageSorting.plist files there; this is where Mail 1.x stored the rules, and they are no longer used by Mail 2.x, so just move them to the Trash if you see them.
    6. Look for the account folders. The name of each account folder starts with the account type (POP, IMAP, Mac), followed by the account username and the incoming mail server. Open each of the account folders, locate the Junk.mbox or Junk.imapmbox folder within it, and move it to the Trash if present.
    7. Go to ~/Library/Mail/Mailboxes/. Locate any Junk.mbox folders there (their name may include the account name in parenthesis), and move them to the Trash.
    Note: Messages in Junk folders with an .mbox suffix are stored locally, and will be lost forever as a result of doing steps 6 and 7. If there is a chance that you have legit messages there and you want to preserve them, move them to another mailbox in Mail first. If you cannot do that for some reason, move the folder to the Desktop (to be imported later), instead of to the Trash. Messages in Junk folders with an .imapmbox suffix are stored on the server and can be deleted blindly (Mail will rebuild those mailboxes automatically).
    8. Open Mail. As a result of removing the rules file, the junk filter will be disabled now. You may want to either tell Mail to go offline immediately after opening it, or shut down the Internet connection before opening Mail, to prevent it from downloading anything until the junk mail filter has been enabled again.
    9. Go to Mail > Preferences > Junk Mail, enable junk filtering, and configure it however you wish.
    10. Go online again if you went offline in step 8.
    If the above solves the problem and you don't have any rules you'd like to preserve or recreating them is not a daunting task, just delete the MessageRules.plist files that were moved to the Desktop and be done with it.
    Note: For those not familiarized with the ~/ notation, it refers to the user's home folder, i.e. ~/Library is the Library folder within the user's home folder. You can easily locate any of the folders referred to in this post by copying the file path here, doing Go > Go to Folder in the Finder, and pasting the file path there.

  • I need some help with Portal - LDAP connection

    Hello...
    Can some one please help me with an issue I have when I try to connect a Portal in version EP6.0, with an LDAP, I go to System Admin --> System Config --> UM Config --> LDAP Server, Test the connection, it's successful, then restarted the server, but I still can't see the users at the LDAP.
    Hope some one can help me soon.
    Miguel

    Hi Miguel,
        After Configuring LDAP to UME portal,You need to create users in the LDAP.Then only you can see the users when you go to user admin->users->search for the user
    1. What happens when you give * to search users?
    2. Are you sure that you have mapped attributes of the user properly in data source configuration Xml file..
    3 Which LDAP server you are using.
    Cheers
    Rani A

  • Please help, Macbook keeps disconnecting me from internet

    Hello, i just bought my macbook pro. Its a Mac OS X ver. 10.5.7 with a 2.26GHz processor.
    I have a Netgear 54mbps wireless router WGR614 v8 and a Motorola SB5100 SURFboard Cable modem.
    Now the problem im having is with the internet connection with my mac. I live in Virginia and It was working before i went on vacation to tennessee which is an hour behind virginia. It was able to connect with no problems. It was also connecting fine in tennessee as well. But when i came back to Virginia, the mac would connect to my router or atleast say its connected but i can't use the internet at all. I would load either firefox, safari, or itunes store and the page would begin to load and then stop loading in the middle. As if it was freezing, dropping the connection or something. When i look through the airport connectivity, it would stay connected to my router with still no access to the internet. I also checked to make sure i was in the correct time zone with my mac and it was correct.I have a wii, xbox, original pc that are connected to router that operate perfectly. its just my macbook wont connect wirelessly when it used to before i went to tennesse and took it with me. Some of the error messages that i get when i try to use the internet via macbook now are "can't open page because the server unexpectedly dropped the connection" but then minutes later it would connect again, then internet would work. But shortly after it would stop working for a while. and the process continues like a cycle. PLEASE HELP BECAUSE IM CLUELESS. i've looked at many forums but no solution.

    OK, I have been having the same problem. I have been renewing my dhcp every 5 min, so frustrating. I don't if this is the answer but this is the first time in a month I have been able to go for more than 3 hours without having to change anything, plus it seems faster. Instead of resetting your modem and router at the same time, unplug them both. 1st plug in your modem, allow it to fully reboot then plug in your router. Seems to have done the trick, good luck.
    PS. I did clone my mac address in my router settings earlier this week.

  • Please help "Alert:no Internet connection"

    My MacBook pro has been acting weird,I can't connect to my airport,I'm using AT&amp;T uverse and for some reason I can't use safari or the app store,please help.It works everywhere else,on my iMac,iPhone 4s and iPod,I don't see what the problem is.
    P.S: it shows a exclamation mark where the wifi thing is

    At the Apple store, you will find out exactly what is wrong.  You may find that the the problem may be fixed for free if it is really simple and requires no parts.  It may be that you will know what to do and be able to fix it yourself.  Until the problem is precisely defined, we can only speculate on what may be wrong.
    If I were in your position I would take it to the store and then I would be able to make an informed decision.  I urge you to do so.
    Ciao.

  • Please help it keeps tellen me to update my flash player and it already has been

    please help keeps tellen me update my flash player and it has already been updated

    Which operating system, browser and Flash Player version are you using?

  • How to keep NetStream.Connect alive even when noone is connected?

    is there any timeout set for NetStream.Connect? I am having an issue when one streamer goes to 2way channel and waits for another party to join but after about 1 minute (if noone is receiving that streamer signal) the NetStream.Connect.Close event is fired up. I want to be able to wait little bit longer.
    Any help much appreciated.

    Dear Alll,
    Please help.

Maybe you are looking for

  • How to get the MIME type of the given file in R/3

    Dear Experts, Please tell me the FM or Class to get the given file MIME type in R/3 . I am using GUI_upload Function module to upload the file in R/3 . Edited by: balaji ramadas on Jan 16, 2009 5:39 AM

  • Dual Monitors on t430

    I just received my new t430 and having issue with dual monitors. I am using the Intel HD 4000. I have it connected to a ThinkPad Port Replicator Series 3 (Type 4336). The docking station only support VGA connection. My new t430 only has a VGA connect

  • Have serious problems with X61s

    Hello. I faced some problems in the last two days with my laptop X61s . First , everything was fine till I tried to connect and install my printer ( HP photosmart 7550 ) on Windows Vista Business edition ( the windows can't recognise the USB device )

  • More Sort Options in App Store Category Views

    I would love to see the ability to sort apps within the various categories of the app store by more than just "Name" and "Release Date" How about adding these: Highest Rating Recently Updated Price Most Purchased I'd like to see a bit of grouping ala

  • Same Frame...Not (Hyperlinking)

    I have RoboHelp installed on my laptop, where I'm working on my project. In one Topic I have references to external links, with the choice to open the resulting link in the same frame (Hyperlink Options-Display In Frame=Same Frame). When I test it on