Interesting sqlnet observation

While doing a setup for a blog article I'm working on, I noticed something very interesting with tns locating its config files.
The whole purpose of the exercise was to demonstrate the interaction of ORACLE_HOME and TNS_PING, in both the registry and as and environment variable on a Windows client.
Here's the setup. I have a stock Oracle 10.2.0.4 client installation on XP-Pro. OHOME is C:\oracle\product\10.2.0\client_1. To prepare for the exercise I create three more directories:
C:\oracle\product\10.2.0\client_2\network\admin
c:\oranet\admin_1
c:\oranet\admin_2each directory got identical copies of both sqlnet.ora and tnsnames.ora
The plan was to add ORACLE_HOME as an environment variable, add TNS_ADMIN to the registry, then TNS_ADMIN to the environment, with each setting pointing to a different directory of the 4 available. After each change, execute tnsping and observe what it reports as "Used parameter files:"
Here's my results as I progressed
Only setting is the real OHOME in the registry - used OHOME\network\admin
Within the cmd session, set ORACLE_HOME=C:\oracle\product\10.2.0\client_2 - tnsping used sqlnet.ora in that directory
add TNS_ADMIN=c:\oranet\admin_1 to the registry- tnsping used that directory
add TNS_ADMIN=c:\oranet\admin_2 to the session environment - tnsping used that directory
To this point, each change was stacked on top of the previous, and each result was what I expected at that point (though as I write this and think of what came later, I'm questioning that. More later)
Next, with all four indicators in place (OHOME in registry and environment, TNS_ADMIN in registry and environment) I started deleting sqlnet.ora from the directories in reverse order, to see where it would go if it couldn't find it in the "preferred" location.
First step of this phase was to delete sqlnet.ora from the directory indicated by TNS_ADMIN as the environment variable. tnsping found sqlnet.ora in the directory indicated by ORACLE_HOME in the environment. So far, so good.
Next I deleted THAT sqlnet.ora (%ORACLE_HOME%\network\admin\sqlnet.ora) and repeated tnsping. Here's where things got strange. The "Used parameter files:" was followed by just a blank line, followed by tns information, and a failed ping due to a TNS-12557: TNS:protocol adapter not loadable. But it DID show the address resolution for mysid.
So the big mystery is if it gave up looking for a sqlnet.ora file (apparently didn't revert to the indicators in the registry) then where did it find a tnsnames.ora file? Why didn't it fail over to the registry for an indication on where to find sqlnet.ora? My first impulse was to set sqlnet client tracing on to get a closer look, but of course with it not finding a sqlnet.ora file, there's no place to turn the tracing on ..
Another question (that I didn't think about on my initial test, but alluded to above) was that at the second step, I added the env variable ORACLE_HOME, and that took precedence over the registry. But when I then added TNS_ADMIN to the registry, THAT took precedence over the session environment. That countered my thought that any session level setting would take precedence over any registry setting.

sb92075 wrote:
You know I'd prefer not to, but this exercise is designed specifically to explore the influences in a Windows client.OK, I'll spell it out.
Oh, good grief! I thought you knew me better than that ... My comment was based on the assumption that you had seen enough of my postings to know I have healthy dislike of Windows.
I don't have Oracle on Windows so I can't test myself.
Does Oracle on Windows use tnsnames.ora or .tnsnames.ora file if it exists in OS User's "HOME" folder?I never thought about that. Since the dot-name construct is specifically a *nix convention it never occured to me to try it on Windows.  I'll add it to this morning's tests.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

Similar Messages

  • Interesting pageout observation

    I have a ton - of pageouts. Currently I have 152,304 pageins and 422,932 pageouts. Hideous. I decided to find what the cause was. I have 4GB ram. I suspected PS CS for all the obvious reasons. I opened Terminal and hit TOP and watched the Pageout numbers as I opened a file I have been working on. It's a highly layered (47 layers) 1.15g file. As the file opened I watched the pageout numbers crank past. It took roughly 30 seconds to open and each second the pageout numbers in parenthesis would go from something like 1000 to 4000 and in between numbers. In that half minute it paged out tens of thousands of times. After the document was open I noted that the Efficiency of it was marked at 69%. This is PS CS mind you...not CS3.
    PS is taking up the full amount of memory I have allocated to it. I allocated 100% in PS Preferences,which turns out to be 1392mb, and Activity monitor shows it using 1.4GB . Safari is using 455mb and overall I still have 318 Free and 970 Inactive as shown in Activity Monitor as the pageouts occur. No big surprise there given PS CS's use of memory.
    Once opened, I am able to work with the document with few if any pageouts. It appears that the pageouts occur only with the opening of the document and once open it is doing few if any pageouts (I've not seen any yet) in spite of the 69% efficiency listed. I assume that at some point I'd see pageouts when working on it but I haven't caught any yet.
    I have not upgraded because of my dislike of Activation. I have no warez on my computer and this is indeed a fully legal copy of CS but I choose to avoid programs that require activation like the plague and CS continues to do what I need it to do. I may upgrade yet but with two machines (Adobe allows install on a second computer) that are constantly tweaked, backed up, hard drives added and swapped in and out, it won't be soon if ever.
    Until I looked at this closely I was unsure of why I had so many pageouts with 4GB of ram when my Free&Inactive ram remained in good shape. The common adage is to add more RAM when you see Pageouts like I have and I almost did so, but this is a case where the only solution would be to upgrade a program, not add RAM. I might still get some pageouts with CS3 but it would be far fewer in number.
    Hope this was helpful to somebody. And to those who can resist commenting on how nicely Activation works or deriding me for not using CS3...have at it.

    PS CS will only let me set the memory for it in Preferences to 1.4GB of RAM. CS3 will use up to 4GB of RAM. With that in mind I think CS3 should pageout far less often than CS does. Because this file has 47 layers, no individual layer is huge and working on any layer does not tax my system at all. Responsiveness and speed is really not a problem. I seemingly never exhaust my Free RAM as indicated by Activiy Monitor and normally have a Gig of ram or so free if you count Free+Inactive so it would seem to me that the limiting factor is PS and how it uses memory, not the actual amount of memory I have. Even as I watch pageouts spin by I have over a GB of Free+Inactive ram, and as I mentioned, the pageouts seemingly only happen as the document is being opened. With all that in mind I think the issue is PS and not how much RAM I actually have; If I am wrong, I'd appreciate more information and in particular a link or reference to the programs that help ascertain the performance of a system. Thanks. If I am indeed wrong on my assumptions, I'll upgrade without hesitation. I have 4x1GB now. I figured another 4x1GB would be the best 8GB config. (but I still am assuming it would not help my particular situation till I can be persuaded differently )

  • Using TIme Machine on a MacBook Pro with an AFP connected External HD

    I have successfully been able to setup my MacBook Pro to use TM to an external drive connected to my MacPro - however there are some interesting limitations/observations/
    To make this configuration work - I had to go into the sharing system preferences and select file sharing and then add that external drive to my shared folders list.
    Now if I have shut down my laptop and then come back home and plug it back into the network via Ethernet - TM will try to run the backup job at its next scheduled time but will fail! What I have to do to make it work is to open a finder window - click on my shared MacPro desktop which then pulls up all of the folders that are shared including the external TM hard drive (by the way), but it will still not be enabled via the system preference. This is especially odd since within the title bar of that finder window - it clearly states that I am connected to this computer as "William Harris" What I then have to do is double click on the folder that represents that external HD and as soon as I do that - the system preference shows the name of the external HD in bold (no longer grayed out) and the TM backup starts immediately!!! This will then continue to work without my intervention until I shut the laptop down again.
    So - the fact that I must manually "re-connect" the connected AFP share point before TM will start to work again IMHO is a bug!
    Anyone else seeing this function working differently?

    gogetgil wrote:
    Run a Synology DS211  and trying to get Time Machine on my MB Pro (Lion) to work with my NAS as backup. It show work...but...My Macbook Pro doesn't recognize the NAS when opening Time Machine, it doesnt show the NAS as an option. However, in Finder it does see my NAS and I can work with it. Can somebody explain in steps (for my MB Pro and NAS) what I am doing wrong?
    I don't use one, but many folks use Synology NASs with Time Machine.  However, a number of 3rd-party NASs need to be updated to work witih Lion, so check with Synology to be sure your model is compatible and/or has the latest updates.
    It can be a bit tricky setting them up, however, as part of it must be done on the NAS, with the NAS's software, so follow Synology's instructions very carefully. 

  • Blur Tool Problem - Random Lines (Adobe CC 2014.2.1 Release)

    Hi,
    I'm hoping that I haven't ticked some obscure option, but I have been using the Blur Tool in Photoshop CC for a while and after the most recent update have had issues with it - basically, when I try to use it to blur a specific area, it randomly goes all over the place (as if I'd grabbed the mouse and moved it rapidly in a random direction).  Obviously if I can't use the blur tool with precision (well, any tool really!) it makes it hard to work!
    Some interesting notes / observations:
    The sharpen tool works perfectly - only sharpens where I point it, which makes me think that it's not an issue with my mouse.  No other tools I use have the issue either - only the blur tool!!
    I have no other pointing devices plugged in (I had a pen tablet plugged in - long story, prefer the mouse over the tablet :-)) so it's not some other pointing device making noise.
    Has anyone else encountered this problem, and if so, how did you resolve it?
    Thanks - blurring and then going into the layer to delete the random lines of blur is getting tiresome - and it's not very precise either.
    Cheers,
    Terence.

    Check out this other thread I started
    http://feedback.photoshop.com/photoshop_family/topics/using-text-tool-freezes-photoshop-cc -2014-2-0-20140926-r-236-x64-release?utm_source=notification&utm_medium=email&utm_campaign =new_reply&utm_content=reply_button&reply[id]=14914157#reply_14914157
    There it's help there.  I've not totally solved my problem but others seemed to have.
    Richard

  • Error when closing Photoshop CS5 Ext- Windows 7

    This isn't a big issue, because at least it happens when I'm done with PS and not while I'm using it, but whenever I exit the program, whether by using the X in the corner or by using File->Close, I get an error afterwards saying "Adobe Photoshop CS5 has stopped working. A problem caused the program to stop working correctly. Please close the program."
    Is there anyway to stop this from happening, because it is rather annoying after a while.

    "Thank you for your support". 
    For what it's worth scratch what I said above about 12.0.1 fixing my own issues.  I'm occasionally seeing Photoshop hanging around after exiting; I just made another post on the subject myself.  Not seeing crashes at that point though.
    I'll bet Chris Cox will find interesting your observation about being a user vs. administrator.
    Photoshop may require write access to files or registry entries that would not necessarily be available to it if you're using the app as a different user than the account under which it was installed.  It will be very interesting to hear what the resolution to this is.  I believe I will create another user and try it to learn what it's trying to access.
    -Noel

  • File rename on rman duplicate

    Oracle 11.2.0.2 SE-One 64-bit
    Oracle Linux 5.6 x86-64
    Question I had never considered.  When performing an rman duplicate database with no NEWNAME parameters in sight, how does rman know how to set new names?  There is something more than just the init parm “db_create_file_dest”.
    The setup:
    Server SRVPRD,
    - ASM instance
    - database DBPRD , has files in diskgroups SAN and SMALL
    Server SRVDEV
    - ASM instance
    - database DBSTG, has files in diskgroups LARGE and SMALL
    - database DBDEV, has files in diskgroups DEV_LARGE and DEV_SMALL
    Shell script on SRVDEV to replicate DBPRD to DBSTG.   Script ftp’s the rman backups from SRVPRD, shuts down the instance DBSTG, deletes all of its files using asmcmd commands, then executes the following:
    echo "connect catalog rman/********@rmcat"       > /backup/dbstgvb/dbstgvb_refresh.rman
    echo "connect target sys/********@srvprd"       >> /backup/dbstgvb/dbstgvb_refresh.rman
    echo "connect auxiliary /"                      >> /backup/dbstgvb/dbstgvb_refresh.rman
    echo "run {"                                    >> /backup/dbstgvb/dbstgvb_refresh.rman
    echo "set until time \"to_date('`date +%Y-%m-%d` 12:38:00','YYYY-MM-DD hh24:mi:ss')\";"  >> /backup/dbstgvb/dbstgvb_refresh.rman
    echo "duplicate target database to DBSTGVB;"    >> /backup/dbstgvb/dbstgvb_refresh.rman
    echo "}"                                        >> /backup/dbstgvb/dbstgvb_refresh.rman
    $ORACLE_HOME/bin/rman < /backup/dbstgvb/dbstgvb_refresh.rman
    It runs perfectly and the files that were in the +SAN diskgroup in prod are correctly placed in +LARGE, and the files that were in +SMALL are correctly placed in +SMALL.   
    Now a new requirement to start doing the same for DBDEV.  Made a copy of the script and changed all references from DBSTG to DBDEV. Equivalent changes in the string of asmcmd commands that delete the files, specifying the correct specific disk groups.
    With this one, instead of mapping files from the two disk groups in DBPRD to the two diskgroups in DBDEV, they all get put into the one disk group +DEV_SMALL.
    On DBSTG, we see
    SQL> show parameter db_create_file_dest
    NAME TYPE VALUE
    db_create_file_dest     string +SMALL
    and the rman log output of the replication includes this:
    database mounted
    contents of Memory Script:
       set until scn  2984496;
       set newname for datafile  1 to
    "+SMALL/dbstgvb/system01.dbf";
       set newname for datafile  2 to
    "+SMALL/dbstgvb/sysaux01.dbf";
       set newname for datafile  3 to
    "+SMALL/dbstgvb/undotbs01.dbf";
       set newname for datafile  4 to
    "+SMALL/dbstgvb/users01.dbf";
       set newname for datafile  5 to
    "+LARGE/dbstgvb/perfstat_01.dbf";
       set newname for datafile  6 to
    "+LARGE/dbstgvb/dw_tbs1.dbf";
       restore
       clone database
    executing Memory Script
    On DBDEV we see
    SQL> show parameter db_create_file_dest
    NAME TYPE VALUE
    db_create_file_dest     string +DEV_SMALL 
    and the rman log output of the replication includes this:
    database mounted
    contents of Memory Script:
       set until scn  2984496;
       set newname for clone datafile  1 to new;
       set newname for clone datafile  2 to new;
       set newname for clone datafile  3 to new;
       set newname for clone datafile  4 to new;
       set newname for clone datafile  5 to new;
       set newname for clone datafile  6 to new;
       restore
       clone database
    executing Memory Script
    So, I am missing exactly how it is that in the replicate to DBSTG, it is able to correctly identify that files coming from prod diskgroup SAN correctly mapped to diskgroup LARGE? And further, why that mechanism did not work to map to +DEV_LARGE when replicating to DBDEV.  In DBDEV it seems to be controlled entirely by db_create_file_dest, but in DBSTG there seems to be something that I am missing that allows the greater complexity of mapping two diskgroups.

    Interesting side observation
    In making sure all files ended up in the correct location I started noticing differences in the FQFN from the source db to the target.   Doing an asmcmd 'ls -l' on both systems, I discovered things like this:
    On the source db, we have
    DW_TBS1.dbf => +SAN/DBPRD/DATAFILE/DW_TBS.278.755044731
    while on the target it came out
    dw_tbs1.dbf => +LARGE/DBSTG/DATAFILE/DW.259.821974713
    or
    STAGE_CUST_ACCT_I1.ora => +SAN/DBPRD/DATAFILE/STAGE_CUST_ACCT_I.262.754925519
    vs
    stage_cust_acct_i1.ora => +LARGE/DBSTG/DATAFILE/STG_CUST_ACCT_IDX.266.822009311
    Obviously not an operational problem, but a curiosity about the algorithm to generate the base part of the FQFN, and why it generated different names on different systems.

  • Zen Touch Display light inbetween track

    Any chance I can have the display light up for a second or two when a new track begins to play? This would be great since I use my Zen Touch in my car and it would be a very helpful feature while driving at night.
    Thanks in advance.

    No, unfortunaltely your player can not do this.
    I have never thought of such an option. For me personally it is of no value, I do not need it, but it is interesting to observe how the needs for more features and options are subject to evolution. I remember myself longing for a muvo, than I wanted something more, than a larger capacity, than some more advanced features and menu options and it never ends. One discovers every day some new needs to improve the usability of...everything. It is never enough...:-)

  • Export Custom Object search results

    I've selected my search criteria in one of my customer objects. The result is a set of records containing specific data items that I need. This data is not available in the contact record. I need to export just this set of records and not my entire Customer Object universe. Is that functionality available? Any help is appreciated.

    Method 1:
    Custom object > Reporting (drop-down from the top-right) > Custom Object Record Field Values (or percentages)
    Select your field, click "Select"
    Click into any field values that interest you
    Observe an exportable list of records
    (Limitation = cannot use wildcards)
    Method 2:
    Insight. This requires the analyzer license. Custom Object Record values are not subject to the normal 24 hour delay that almost all other data is. At most there is a ~30 second delay between CDOs and Insight.
    Ensure that the Custom Object Record and the fields from it you want are available in Insight. You want to include your unique field because the values are deduplicated in Insight otherwise. Build a report that includes the unique field and the field your value of interest is in. Filter on the column of interest and run the report. Export as desired.
    Method 3:
    API. From any open Eloqua window where you've already logged in, go to this URL: https://secure.eloqua.com/api/docs/dynamic/rest/1.0/reference.aspx
    (This is not for the tame and feint of heart.)
    More help here: Code It
    Specifically here: Building On The Eloqua Platform - A Resource Guide
    And here: Eloqua REST API - Create and Manage Custom Objects
    -Alexander Huzar

  • XY Curve Plot in Labview

    Hi Everybody,
    I am a beginer to Labview and NI-ElVIS and as a begineer I am facing
    some (maybe) trivial issue. Unfortunately I was not able to find
    solution to the query and hence an looking forward to your help.
    I have designed a circuit in NI-ELVIS and an viewing the output in
    oscilloscope of NI-ELVIS software. However I am interested in plotting
    XY- graph for the two channels that I am interested in observing. Can
    anyone help me how can I do that ?
    To make the problem a little more complicated, I am interested in
    varying the supply voltages on NI-ELVIS board and would like to observe
    the XY graph with respect to variation in voltages I am performing.
    Currently I am using manual mode of ELVIS but I would like to control
    the same through hardware alongwith plotting the XY curve.
    Thanks,
    -Gaurav

    Hii, Dennis
             Please explain me why this is happening, i am converting this using the option save with options and there is an option that save with version 7.0 at the left pan, but it is still not converted, when we are doing that in LabVIEW 8.0, to convert it into the LabVIEW 7.1, it is running OK, i mean it is not giving any error, why this is happening?
     And Gaurav sorry, i dont know whu it is not happening? i think it should br there, but?????? i don know yaar!
    Thanks,
    Nishant 
    Message Edited by Nishant on 04-14-2006 09:20 AM

  • Implementing "critical sections" using recursive mutex locks

    Greetings.
    I have chosen pthread mutexes for implementing critical sections in my ported Windows code. As you probably all know, mutexes do not by default support recursive locking and will deadlock if attempted. With Solaris 7 came support for recursive locking through the PTHREAD_MUTEX_RECURSIVE type of mutex. The problem I have encountered when using these recursive mutexes doesn't even involve recursive locking, yet only manifests itself when using the recursive type.
    To pin-point the problem, I have written a very simple application that creates 10 threads and pauses (via sleep()) for an amount of time sufficient for all threads to complete. In each thread, a global mutex (recursive type) is locked and then immediately unlocked, with status going to stdout via printf. There is no problem with this simple application and all threads run to completion after each gets the mutex lock in succession. To really test the mutex however, I simulated a pre-empted or otherwise blocked thread via a call to sched_yield() after locking the mutex and before unlocking it. In this version of the application, only the first thread to acquire the mutex lock completes (after successfully locking and unlocking the mutex), and all other threads hang waiting to acquire the mutex lock.
    Any insight on this problem or suspected problems with the code I described would be GREATLY appreciated! I would be happy to send the source to this simple application to anyone interested in observing it's behavior.
    Regards and thanks in advance.
    Chad Attermann
    telic.net

    Solaris 7 is shipped broken for recursive mutexes... You can fix it by using patch 106980-13 and everything it depends on...
    Good luck!

  • RGB values of current terminal color settings?

    The colors displayed for different ANSI escape codes are configurable via .Xdefaults or directly on the command line via other ANSI escapes.
    Is there any way to dump the current values from a terminal? For example, given the ANSI escape code "\033[31m", I would like to know the current RGB values used to display it.
    Obviously this will depend on the terminal (e.g. urxvt can have different settings from xterm), but I'm hoping that there is some obscure tool to do this.

    Coincidentally, I recently wrote a script to do exactly this: query all the color values from a terminal emulator and show them in a nice table. I was planning to make a thread for this, but this thread is perfect.  In my opinion, the strategy of querying colors from the terminal itself is superior (when it is supported by the terminal) to mucking around with .Xresources, .Xdefaults, or "xrdb --query", which only work in pretty limited situations. The drawbacks of my approach are: (1) it can be challenging to make the same code work on different terminal emulators, and (2) you have to use it from the terminal you want to query, and not from within a screen or tmux session. (I think there may be partial workarounds for (2), but I haven't implemented them.) I've tested my code on a number of terminals, and the upshot is that xterm and urxvt are supported flawlessly, and VTE-based terminals like gnome-terminal and XFCE's "Terminal" are almost fully supported. (I wasn't able to query the default foreground and background colors, but everything else seems to work.) Most other X terminals don't seem to support this method of querying color values.
    Here's an example of what the script produces:
    Obviously, that's a heavily formatted table, but I think the code has enough comments that you can take what you need from it. It works under python 3 or python 2.7.
    Edit: This version is superseded by the one in post #27, which is structured better. I'm leaving this here since some of the future replies refer to it.
    #!/usr/bin/python
    This is a Python script to show off your terminal ANSI colors (or more
    colors, if your terminal has them). It works on both Python 2.7 and
    Python 3.
    This script must be run from the terminal whose colors you want to
    showcase. Not all terminal types are supported (see below). At the
    very minimum, 16-color support is required.
    Fully supported terminals:
    xterm
    urxvt
    For these terminals, this script can show a color table with correct RGB
    values for each color. It queries the RGB values from the terminal
    itself, so it works even if you change the colors after starting the
    terminal.
    Mostly supported terminals: pretty much all VTE-based terminals. This
    includes:
    vte
    Terminal (XFCE)
    gnome-terminal
    terminator
    tilda
    and many more. These are on "mostly" status because I don't know how to
    query their foreground and background colors. Everything else works,
    though, albeit with noticeable slowness (which may be beyond this
    script's control).
    Somewhat supported terminals: pretty much all other X-client terminals
    I've tried. These include:
    konsole (KDE)
    terminology (Enlightenment)
    Eterm (Enlightenment)
    (etc.)
    For these terminals, the script can output a color table just fine, but
    without RGB values.
    Unsupported terminals:
    ajaxterm
    Linux virtual console (i.e., basic TTY without X-windows)
    Warning: do not run this script on the Linux virtual console unless you
    want a garbled TTY! That said, you can still type `tput reset<Enter>'
    afterward to get back to a usable console. :-) The situation with
    ajaxterm is similar, but not as bad.
    If a terminal isn't mentioned here, I probably haven't tried it. Attempt
    at your own risk!
    Note regarding screen/tmux: this script can theoretically be run from a
    screen or tmux session, but you will not get any RGB values in the
    output (indeed, a screen session can be opened on multiple terminals
    simultaneously, so there typically isn't a well defined color value for
    a given index). However, it's interesting to observe that screen and
    tmux emulate a 256 color terminal independently of the terminal(s)
    to which they are attached, which is very apparent if you run the script
    with 256-color output on a screen session attached to a terminal with 8-
    or 16-color terminfo (or with $TERM set to such).
    This code is licensed under the terms of the GNU General Public License:
    http://www.gnu.org/licenses/gpl-3.0.html
    and with absolutely no warranty. All use is strictly at your own risk.
    from sys import stdin, stdout, stderr
    import re
    import select
    import termios
    from collections import defaultdict
    from argparse import (ArgumentParser, ArgumentError)
    # Operating system command
    osc = "\033]"
    # String terminator
    # ("\033\\" is another option, but "\007" seems to be understood by
    # more terminals. Terminology, for example, doesn't seem to like
    # "\033\\".)
    st = "\007"
    # Control sequence introducer
    csi = "\033["
    # ANSI SGR0
    reset = csi + 'm'
    # Errors that may be raised by rgb_query
    num_errors = 0
    class InvalidResponseError(Exception):
    The terminal's response couldn't be parsed.
    def __init__(self, q, r):
    global num_errors
    num_errors += 1
    Exception.__init__(self, "Couldn't parse response " + repr(r) +
    " to query " + repr(q))
    class NoResponseError(Exception):
    The terminal didn't respond, or we were too impatient.
    def __init__(self, q):
    global num_errors
    num_errors += 1
    Exception.__init__(self, "Timeout on query " + repr(q))
    # Wrappers for xterm & urxvt operating system controls.
    # These codes are all common to xterm and urxvt. Their responses aren't
    # always in the same format (xterm generally being more consistent), but
    # the regular expression used to parse the responses is general enough
    # to work for both.
    # Note: none of these functions is remotely thread-safe.
    def get_fg(timeout):
    Get the terminal's foreground (text) color as a 6-digit
    hexadecimal string.
    return rgb_query([10], timeout)
    def get_bg(timeout):
    Get the terminal's background color as a 6-digit hexadecimal
    string.
    return rgb_query([11], timeout)
    def get_color(a, timeout):
    Get color a as a 6-digit hexadecimal string.
    return rgb_query([4, a], timeout)
    def test_fg(timeout):
    Return True if the terminal responds to the "get foreground" query
    within the time limit and False otherwise.
    return test_rgb_query([10], timeout)
    def test_bg(timeout):
    Return True if the terminal responds to the "get background" query
    within the time limit and False otherwise.
    return test_rgb_query([11], timeout)
    def test_color(timeout):
    Return True if the terminal responds to the "get color 0" query
    within the time limit and False otherwise.
    return test_rgb_query([4, 0], timeout)
    def test_rgb_query(q, timeout):
    Determine if the terminal supports query q.
    Arguments: `q' and `timeout' have the same interpretation as in
    rgb_query().
    Return: True if the terminal gives a valid response within the
    time limit and False otherwise.
    This function will not raise InvalidResponseError or
    NoResponseError, but any other errors raised by rgb_query will
    be propagated.
    try:
    rgb_query(q, timeout)
    return True
    except (InvalidResponseError, NoResponseError):
    return False
    # String to use for color values that couldn't be determined
    rgb_placeholder = '??????'
    # This is what we expect the terminal's response to a query for a color
    # to look like. If we didn't care about urxvt, we could get away with a
    # simpler implementation here, since xterm and vte seem to give pretty
    # consistent and systematic responses. But I actually use urxvt most of
    # the time, so....
    ndec = "[0-9]+"
    nhex = "[0-9a-fA-F]+"
    crgb = ("\033\\]({ndec};)+rgba?:" +
    "({nhex})/({nhex})/({nhex})(/({nhex}))?").format(**vars())
    re_response = re.compile(crgb)
    # The problem I'm attempting to work around with this complicated
    # implementation is that if you supply a terminal with a query that it
    # does not recognize or does not have a good response to, it will simply
    # not respond *at all* rather than signaling the error in any way.
    # Moreover, there is a large variation in how long terminals take to
    # respond to valid queries, so it's difficult to know whether the
    # terminal has decided not to respond at all or it needs more time.
    # This is why rgb_query has a user-settable timeout.
    P = select.poll()
    P.register(stdin.fileno(), select.POLLIN)
    def flush_input():
    Discard any input that can be read at this moment.
    repeat = True
    while repeat:
    evs = P.poll(0)
    if len(evs) > 0:
    stdin.read()
    repeat = True
    else:
    repeat = False
    def rgb_query(q, timeout=-1):
    Query a color-valued terminal parameter.
    Arguments:
    q: The query code as a sequence of nonnegative integers, i.e.,
    [q0, q1, ...] if the escape sequence in pseudo-Python is
    "\033]{q0};{q1};...;?\007"
    timeout: how long to wait for a response. (negative means
    wait indefinitely if necessary)
    Return: the color value as a 6-digit hexadecimal string.
    Errors:
    NoResponseError will be raised if the query times out.
    InvalidResponseError will be raised if the terminal's
    response can't be parsed.
    See
    http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
    ("Operating System Controls") to see the various queries
    supported by xterm. Urxvt supports some, but not all, of them,
    and has a number of its own (see man -s7 urxvt).
    Warning: before calling this function, make sure the terminal is
    in noncanonical, non-blocking mode.
    query = osc + ';'.join([str(k) for k in q]) + ';?' + st
    flush_input()
    stdout.write(query)
    stdout.flush()
    # This is addmittedly flawed, since it assumes the entire response
    # will appear in one shot. It seems to work in practice, though.
    evs = P.poll(timeout)
    if len(evs) == 0:
    raise NoResponseError(query)
    r = stdin.read()
    m = re_response.search(r)
    if not m:
    raise InvalidResponseError(query, r)
    # (possibly overkill, since I've never seen anything but 4-digit RGB
    # components in responses from terminals, in which case `nd' is 4
    # and `u' is 0xffff, and the following can be simplified as well
    # (and parse_component can be eliminated))
    nd = len(m.group(2))
    u = int('f'*nd, 16)
    # An "rgba"-type reply (for urxvt) is apparently actually
    # rgba:{alpha}/{alpha * red}/{alpha * green}/{alpha * blue}
    # I opt to extract the actual RGB values by eliminating alpha. (In
    # other words, the alpha value is discarded completely in the
    # reported color value, which is a compromise I make in order to get
    # an intuitive and compact output.)
    if m.group(5):
    # There is an alpha component
    alpha = float(int(m.group(2), 16))/u
    idx = [3, 4, 6]
    else:
    # There is no alpha component
    alpha = 1.0
    idx = [2, 3, 4]
    c_fmt = '%0' + ('%d' % nd) + 'x'
    components = [int(m.group(i), 16) for i in idx]
    t = tuple(parse_component(c_fmt % (c/alpha)) for c in components)
    return "%02X%02X%02X" % t
    def parse_component(s):
    Take a string representation of a hexadecimal integer and transorm
    the two most significant digits into an actual integer (or double
    the string if it has only one character).
    n = len(s)
    if n == 1:
    s += s
    elif n > 2:
    s = s[:2]
    return int(s, 16)
    def test_num_colors(timeout):
    Attempt to determine the number of colors we are able to query from
    the terminal. timeout is measured in milliseconds and has the same
    interpretation as in rgb_query. A larger timeout is safer but will
    cause this function to take proportionally more time.
    if not test_color(timeout):
    return 0
    a = 0
    b = 1
    while test_rgb_query([4, b], timeout):
    a = b
    b += b
    while b - a > 1:
    c = (a + b)>>1
    if test_rgb_query([4, c], timeout):
    a = c
    else:
    b = c
    return b
    class ColorDisplay(object):
    Class for producing a colored display of terminal RGB values.
    def __init__(self, timeout=100, color_level=3, do_query=True):
    timeout: same interpretation as in rgb_query. A larger timeout
    will be used a small number of times to test the
    capabilities of the terminal.
    color_level: how much color should be in the output. Use 0 to
    suppress all color and 3 or greater for maximum coloredness.
    do_query: whether to attempt to query RGB values from the
    terminal or just use placeholders everywhere
    self.timeout=timeout
    self.color_level=color_level
    # try getting the rgb value for color 0 to decide whether to
    # bother trying to query any more colors.
    self.do_query = do_query and test_color(self.timeout*5)
    def none_factory():
    return None
    # colors for highlighting
    self.hi = defaultdict(none_factory)
    self.hi['['] = 10
    self.hi[']'] = 10
    self.hi['+'] = 9
    self.hi['/'] = 9
    for c in '0123456789ABCDEF':
    self.hi[c] = 12
    def show_ansi(self):
    Show the 16 ANSI colors (colors 0-15).
    color_order = [0, 1, 3, 2, 6, 4, 5, 7]
    names = [' Black ', ' Red ', ' Green ', ' Yellow ',
    ' Blue ', ' Magenta', ' Cyan ', ' White ']
    stdout.write(self.fgcolor('15', 3))
    for k in range(8):
    a = color_order[k]
    stdout.write(names[a])
    stdout.write('\n')
    stdout.write(self.fgcolor(None, 3))
    c = None
    for k in range(8):
    a = color_order[k]
    c = self.hiprint(' [%X/%X] ' % (a, 8 + a), c)
    stdout.write('\n')
    self.show_color_table([0,8], color_order)
    def show_color_cube(self, n):
    Show the "RGB cube" (xterm colors 16-231 (256-color) or 16-79
    (88-color)). The cube has sides of length 6 or 4 (for 256-color
    or 88-color, respectively).
    base = {256:6, 88:4}[n]
    c = None
    c = self.hiprint('[ + ] ', c)
    for w in range(base):
    c = self.hiprint('[%X] ' % w, c)
    stdout.write('\n\n' + self.fgcolor(None, 3))
    for u in range(base):
    for v in range(base):
    stdout.write(' '*v)
    x = (u*base + v)*base
    self.hiprint(' [%02X] ' % (16 + x))
    for w in range(base):
    self.show_color(x + w + 16)
    stdout.write('\n')
    stdout.write('\n\n')
    def show_grayscale_ramp(self, end):
    Show the "grayscale ramp" (xterm colors 232-255 (256-color) or
    80-87 (88-color)).
    start = {256:232, 88:80}[end]
    n = end - start
    vals = [self.get_color(a) for a in range(start, end)]
    #stdout.write(reset)
    c = None
    c = self.hiprint('[ ', c)
    for v in range(n):
    c = self.hiprint('%02X ' % (start + v), c)
    c = self.hiprint(']\n', c)
    stdout.write('\n ' + self.fgcolor(None, 3))
    for v in range(n):
    stdout.write(' ' + self.block(start + v, 2))
    stdout.write('\n ')
    for u in range(3):
    for v in range(n):
    stdout.write(' ')
    stdout.write(self.fgcolor(start + v, 2))
    stdout.write(vals[v][2*u : 2*(u + 1)])
    stdout.write(self.fgcolor(None, 2))
    stdout.write('\n ')
    stdout.write('\n')
    def show_colors(self, n):
    Make a table showing colors 0 through n-1.
    self.show_color_table(range(0,n,8), range(8), n, True)
    def show_color_table(self, rows, cols, stop=-1, label=False):
    Make a color table with all possible color indices of the form
    rows[k] + cols[j] that are less than `stop' (if `stop' is not
    negative). If label is True, then print row and column labels.
    if label:
    self.hiprint('[ + ]')
    stdout.write(self.fgcolor(None, 3))
    for a in cols:
    stdout.write(' ' + self.octal(a) + ' ')
    stdout.write('\n')
    if label:
    stdout.write(' ')
    stdout.write('\n')
    for b in rows:
    if label:
    stdout.write(self.octal(b) + ' ')
    for a in cols:
    c = a + b
    if stop < 0 or c < stop:
    self.show_color(b + a)
    else:
    stdout.write(' ')
    stdout.write('\n')
    stdout.write('\n')
    def show_color(self, a):
    Make a pretty display of color number `a', showing a block of
    that color followed by the 6-character hexadecimal code for the
    color.
    stdout.write(' ' + self.block(a) + ' ')
    stdout.write(self.fgcolor(a, 2) + (self.get_color(a)))
    stdout.write(self.fgcolor(None, 2))
    def hiprint(self, s, last_color=-1):
    Print s to stdout, highlighting digits, brackets, etc. if the
    color level allows it.
    Arguments:
    s: the string to print.
    last_color: the current terminal foreground color. This
    should be `None' if no color is set, or the current
    color index, or something else (like a negative integer)
    if the color isn't known. (The last option is always
    safe and will force this function to do the right
    thing.)
    Return: the current foreground color, which can be passed as
    last_color to the next call if the color isn't changed in
    between.
    for c in s:
    if c == ' ':
    color = last_color
    else:
    color = self.hi[c]
    if color != last_color:
    stdout.write(self.fgcolor(color, 3))
    stdout.write(c)
    last_color = color
    return last_color
    def octal(self, x):
    Return a base-8 string for the integer x, highlighted if the
    color level allows it.
    return self.fgcolor(self.hi['+'], 3) + '0' + \
    self.fgcolor(self.hi['0'], 3) + ('%03o' % x)
    def block(self, c, n=1):
    Return a string that prints as a block of color `c' and size `n'.
    return self.bgcolor(c, 1) + ' '*n + self.bgcolor(None, 1)
    # Changing the foreground and background colors.
    # While the 38;5 and 48;5 SGR codes are less portable than the usual
    # 30-37 and 40-47, these codes seem to be fairly widely implemented (on
    # X-windows terminals, screen, and tmux) and support the whole color
    # range, as opposed to just colors 0-8. They also make it very easy to
    # set the background to a given color without needing to mess around
    # with bold or reverse video (which are hardly portable themselves).
    # This is useful even for the 16 ANSI colors.
    def fgcolor(self, a=None, level=-1):
    Return a string designed to set the foreground color to `a' when
    printed to the terminal. None means default.
    if self.color_level >= level:
    if a is None:
    return csi + '39m'
    else:
    return csi + '38;5;' + str(a) + 'm'
    else:
    return ''
    def bgcolor(self, a=None, level=-1):
    Return a string designed to set the background color to `a' when
    printed to the terminal. None means default.
    if self.color_level >= level:
    if a is None:
    return csi + '49m'
    else:
    return csi + '48;5;' + str(a) + 'm'
    else:
    return ''
    def get_color(self, a):
    if self.do_query:
    try:
    return get_color(a, timeout=self.timeout)
    except (InvalidResponseError, NoResponseError):
    return rgb_placeholder
    else:
    return rgb_placeholder
    # Command-line arguments
    timeout_dft = 200
    parser = ArgumentParser(
    description="Python script to show off terminal colors.",
    epilog="Run this script from the terminal whose colors " +
    "you want to showcase. " +
    "For a brief synopsis of which terminal types are " +
    "supported, see the top of the source code.")
    mode_group = parser.add_mutually_exclusive_group()
    p_choices = [16, 88, 256]
    arg_p = mode_group.add_argument(
    '-p', '--pretty',
    action='store_true', default=False,
    help="show colors 0 through N-1 in a pretty format. " +
    ("N must belong to %r. " % p_choices) +
    "If N > 16, it should be the actual number of colors " +
    "supported by the terminal, or the output will almost " +
    "certainly not be pretty.")
    mode_group.add_argument(
    '-f', '--flat',
    action='store_true', default=False,
    help="show a simple table with colors 0 through N-1. ")
    parser.add_argument(
    'n', nargs='?', metavar='N',
    type=int, default=16,
    help="number of colors to show. " +
    "Unless you explicitly supply -p/--pretty or -f/--flat, " +
    "--pretty is used if possible and --flat is used " +
    "otherwise. " +
    "N defaults to 16, showing the ANSI colors 0-15. " +
    "If N is 0, the script will attempt to determine the " +
    "maximum number of colors automatically " +
    "(which may be slow).")
    parser.add_argument(
    '--no-fgbg',
    action='store_false', dest='fgbg', default=True,
    help="suppress display of foreground/background colors.")
    parser.add_argument(
    '--no-query',
    action='store_false', dest='do_query', default=True,
    help="don't try to query any RGB values from the terminal " +
    "and just use placeholders.")
    parser.add_argument(
    '-t', '--timeout', metavar='T',
    type=int, default=timeout_dft,
    help="how long to wait for the terminal to "
    "respond to a query, in milliseconds " +
    "[default: {0}]. ".format(timeout_dft) +
    "If your output has '?' characters " +
    "instead of RGB values " +
    "or junk printed after the script runs, " +
    "increasing this value may or may not " +
    "help, depending on the terminal. " +
    "A negative T will behave like infinity.")
    parser.add_argument(
    '-l', '--level', metavar='L',
    type=int, default=3,
    help="choose how much color to use in the output. " +
    "(0 = no color; 3 = most color [default])")
    if __name__ == '__main__':
    args = parser.parse_args()
    assert not (args.pretty and args.flat)
    if args.pretty:
    if args.n not in p_choices:
    raise ArgumentError(
    arg_p,
    "N must belong to %r" % p_choices)
    tc_save = None
    try:
    tc_save = termios.tcgetattr(stdout.fileno())
    tc = termios.tcgetattr(stdout.fileno())
    # Don't echo the terminal's responses
    tc[3] &= ~termios.ECHO
    # Noncanonical mode (i.e., disable buffering on the terminal
    # level)
    tc[3] &= ~termios.ICANON
    # Make input non-blocking
    tc[6][termios.VMIN] = 0
    tc[6][termios.VTIME] = 0
    termios.tcsetattr(stdout.fileno(), termios.TCSANOW, tc)
    if args.n == 0:
    args.n = test_num_colors(args.timeout)
    # We are guaranteed to have failed some queries now, but
    # that isn't meaningful.
    num_errors = 0
    if not (args.pretty or args.flat):
    if args.n in p_choices:
    args.pretty = True
    else:
    args.flat = True
    if args.level >= 1:
    stdout.write(reset)
    if args.fgbg:
    if args.do_query:
    try:
    bg = get_bg(timeout=args.timeout)
    except (InvalidResponseError, NoResponseError):
    bg = rgb_placeholder
    try:
    fg = get_fg(timeout=args.timeout)
    except (InvalidResponseError, NoResponseError):
    fg = rgb_placeholder
    else:
    bg = rgb_placeholder
    fg = rgb_placeholder
    stdout.write("\n Background: %s\n" % bg)
    stdout.write(" Foreground: %s\n\n" % fg)
    C = ColorDisplay(args.timeout, args.level, args.do_query)
    if args.pretty:
    assert args.n in p_choices
    stdout.write('\n ANSI colors:\n\n')
    C.show_ansi()
    if args.n > 16:
    stdout.write('\n RGB cube:\n\n')
    C.show_color_cube(args.n)
    stdout.write(' Grayscale ramp:\n\n')
    C.show_grayscale_ramp(args.n)
    else:
    C.show_colors(args.n)
    if num_errors > 0:
    stderr.write("Warning: not all queries succeeded\n" +
    "Warning: (output contains " +
    "placeholders and may be inaccurate)\n")
    finally:
    if args.level >= 1:
    stdout.write(reset)
    flush_input()
    if tc_save != None:
    termios.tcsetattr(stdout.fileno(),
    termios.TCSANOW, tc_save)
    Run it as
    python showcolors.py -h
    to get an overview of the functionality.
    TL;DR: you can echo a string like "\033]4;13;?\007" to an xterm, and it will output the RGB value of color #13 to itself in the form "\033]4;13;rgb:rrrr/gggg/bbbb\007", which you can then read and parse. To try it out:
    $ echo -en "\033]4;13;?\007"
    There are some subtleties if you want this to work on other terminals like urxvt; for that you can experiment yourself or read the code. 
    Further reading: http://invisible-island.net/xterm/ctlseqs/ctlseqs.html (heading "Operating System Controls").
    Xyne, regarding determining the number of colors: I don't know how to do that completely reliably. You can try simply
    tput colors
    but this relies on the value of $TERM and its terminfo and thus may be unreliable. A kludgy but workable way to do this using the "rgb_query" function in my script is to query color values using binary search to find the highest color value the terminal will allow you to query. The main problem with this is that if you query an invalid color index, then the terminal just won't respond at all, and if you query a valid index, it will respond but after a somewhat unpredictable delay, so it's hard to know for sure which one is the case. Like I said, it's kludgy but workable.
    Edit: I went ahead and added that functionality to my script. Try running it as
    python showcolors.py 0
    or look at the function "test_num_colors".
    Last edited by Lux Perpetua (2012-10-22 11:18:21)

  • Apple tv dropping wifi

    How do I keep my apple tv from dropping its wi-fi connection? All my other devices hold their wi-fi signal.

    Had the same issues, got my originial AppleTV replaced yesterday - but the trouble with Wifi continued. So I did some investigation. Not sure if this is of help for anyone but it seems that I am able to provoke the "WiFi connection" drop. That's my setup:
    AppleTV 3rd Gen, Software Version 6.0.1;  static IP address
    Airport Extreme 2nd Gen Software 7.6.4; Bridge Mode activated; static IP address; WPA2 enabled; SSID not broadcasted;
    A bunch of other Apple devices on the same Wifi network - all working without any issues!!
    1st scenario: Mac-Address filtering/access control disabled on Airport Extreme
    --> Apple TV finds and connects immediataly to the network.
    2nd scenario: Mac-address filtering/access control enabled on Airport Extreme:
    --> Apple TV does not find/connect to network (YES, correct AppleTV MAC-address has been entered into Airport Extreme's filter list)
    Interesting additional observation: Using a LAN scanner software I get confusing results:
    In the 1st scenario the AppleTV shows up with its correct MAC-address (together with the correct assigend static IP-address)
    But in the 2nd scenario I get a strange result: The correct static IP address of the AppleTV is now assigend to the MAC-address of the Airport Extreme. VERY STRANGE!!
    I reported this to Apple support today - they need to check and will come back.
    Anyways - perhaps you can check if disabling the MAC-addess filtering/access control let Apple TV connrct to WIFi again.
    In my case disabling solved the WIFI connection issue of Apple TV but is not an acceptable solution as I rely on MAC-address filtering/access control due to security reasons.

  • Apple lab management software?

    Is there an Apple lab management software I can use in my classroom?  I'm interested in observing my student's activities and if possible, limit some network access (such as YouTube music videos) when they are supposed to be doing something locally.  Thanks!

    Apple Remote Desktop is the obvious choice for observation, control, and management.  If you are looking to block certain sites, you can use the Parental Controls or push the filtering to the schools content filter.  The challenge is if you want access to YouTube but not access to music videos on YouTube.  I do not think there is a granular method to selectively block specific types of content on the site.

  • Java.sql.SQLException: Closed Statement

    I'm having a problem with my Java code trying to access an Oracle 10g database through the JDBC driver using the Oracle XML Publisher.
    We generate a number of different reports, but one report consistently fails with the error: java.sql.SQLException: Closed Statement
    It only happens in the production environment, which has significantly more data than the test and development environments.
    One interesting (!) observation is that the error occurs after 10 minutes to the second (almost). Which leads me to think it is a timeout related problem, but am aware that this could be a red herring.
    And finally, the code is being run within a job sheduled using the Quartz Scheduler v1.6.5.
    Any help would be appreciated.
    Many Thanks
    Lawrence
    Here is the stack trace:
    java.sql.SQLException: Closed Statement: getMetaData
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:112)
    at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:146)
    at oracle.jdbc.driver.OracleResultSetImpl.getMetaData(OracleResultSetImpl.java:128)
    at com.mchange.v2.c3p0.impl.NewProxyResultSet.getMetaData(NewProxyResultSet.java:47)
    at oracle.apps.xdo.dataengine.XMLPGEN.processSQLDataSource(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.writeData(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.writeGroup(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.writeGroup(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.processSQLDataSource(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.writeData(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.writeGroupStructure(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.processData(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.processXML(Unknown Source)
    at oracle.apps.xdo.dataengine.XMLPGEN.writeXML(Unknown Source)
    at oracle.apps.xdo.dataengine.DataProcessor.processDataStructre(Unknown Source)
    at oracle.apps.xdo.dataengine.DataProcessor.processData(Unknown Source)
    at com.tmobile.sett.file.invoice.InvoiceFileFactory.generateXML(InvoiceFileFactory.java:157)
    at com.tmobile.sett.file.invoice.InvoiceFileFactory.generateStatements(InvoiceFileFactory.java:365)
    at com.tmobile.sett.file.invoice.InvoiceFileFactory.generateInvoices(InvoiceFileFactory.java:457)
    at com.tmobile.sett.file.invoice.StatementGeneratorJob.execute(StatementGeneratorJob.java:34)
    at org.quartz.core.JobRunShell.run(JobRunShell.java:202)
    at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:525)
    Here is the code:
    private void generateXML(String xmlTemplate, String xmlFilename, Hashtable parameters) {
    DataProcessor dataProcessor = new DataProcessor();
    log.debug("generateXML: xmlTemplate {}, xmlFilename {}", xmlTemplate, xmlFilename);
    try {
    // Set Data Template to be executed
    dataProcessor.setDataTemplate(xmlTemplate);
    // Obtain a new Connection from the Pool
    Connection conn = HibernateUtil.getConnection();
    if (conn == null)
    log.debug("conn is null after getCall");
    if (conn.isClosed())
    log.debug("conn is closed after getCall");
    // Set the Connection for the dataProcessor
    dataProcessor.setConnection(conn);
    if (conn.isClosed())
    log.debug("conn is closed after setConnection");
    dataProcessor.setParameters(parameters);
    if (conn.isClosed())
    log.debug("conn is closed after setParameters");
    // Specify the output directory and file for the data file
    dataProcessor.setOutput(xmlFilename);
    if (conn.isClosed())
    log.debug("conn is closed after setOutput");
    // Process the data template
    dataProcessor.processData();
    if (conn.isClosed())
    log.debug("conn is closed after processData");
    // Return the connection to the pool
    conn.close();
    } catch (Exception e) {
    System.err.println("Error generating XML with the following parameters:");
    System.err.println("xmlTemplate=" + xmlTemplate);
    System.err.println("xmlFilename=" + xmlFilename);
    System.err.println("Here's the stack trace");
    e.printStackTrace();
    System.exit(1);
    }

    I have made some progress in understanding the problem...
    Basically, your comment about threads made me look at the code from a threads perspective. There are only three objects used, log4j, oracleXML Publisher and hibernate. Discounting log4j, the Oracle object is created, opened and closed within the procedure, so I concluded that hibernate was the most likely cause of the problem (i know, theres an element of educated guesswork in this).
    Anyway, I found the hibernate timeouts (all around 300 seconds) and increased them to 3000 seconds... and lo and behold the reports are generated successfully, although some of them take over 20 minutes each.
    So, this is a performance problem with the SQL itself:
    SELECT service
    , reply
    , ROUND(SUM(DECODE(op, 3, 0, count))* :uplift,0) x_events
    , ROUND(SUM(DECODE(op, 3, count, 0))* :uplift,0) y_events
    FROM aggregate
    WHERE ref_time >= :period_start
    AND ref_time < :period_end
    AND feed = 13
    AND agreement = :agreement
    AND line = 1
    GROUP BY service, reply
    ORDER BY 1,2
    The SQL in question is querying data for a specific month from a monthly partitioned table that contains about 11 million records a month. We currently have 99 partitions.
    Executing the sql in Toad / Sql developer / sqlplus takes around 20 seconds...so why 20 minutes?
    Looking in the session browser, I can see that the 20 minute query is looking through all 99 partitions where the 20 second query is only looking at 1 partition for the month in question.
    I'm not sure if this is heading off topic for the forum thread, but the question now is...
    Why is Oracle using a clearly innefficient execution plan when we are using a query with bound variables and how do we get it to use a more efficient execution plan?

  • PSE5 problem

    I'm importing colour slides from a scanner, but after one or two imports Organizer crashes. What am I doing wrong?

    WRSH wrote:
    Thank you for taking the trouble to follow this matter up.
    My comment regarding the save process related to your
    'suggestion 2
    Your general description of the problem on your specific system suggests
    that timing of execution of the save process is a factor in your failures.'
    and I thought you were suggesting I might have been hasty in pressing the
    Save button thus confusing the computer. Which seemed to me to quite likely
    because all such actions are effected through my programmed mouse keys,
    buttons etc and not those on the screen.
    Interesting thought.
    Originally I was thinking that the timing was internal to your PC (like the combination of processor, access from the processor to the RAM memory, and access to the disk drive to update the catalog).
    However, now that you have mentioned it, yes it would be interesting to observe the rate at which you do the Save and see if it makes any difference.   If you can isolate any time relationship (like waiting longer between Saves) or pattern of activity that helps to avoid the problem, please do post back to this thread for the benefit of others.

Maybe you are looking for