Help plz regarding array and DB

hi ,
i have a problem regarding sorting.
I have 1 million records in my DB table.
When i open my swing application i sort the records in table [ORDER BY col1,col3,col4] like that and want that order record ids .
upto here no problem.i am getting the ids in array and in my swing application when i go next i get from arrray the next record.
but the problem is since the volume of the table is large if any addition r deletion to the table is not reflecting in the sorted order array.
i can simply again call the database and sort it an update the error.but it proved very insufficent way.
so i am looking something to optmise the sorting.
i got an idea like using view .but i am looking anybody knows any workaround alogrithm for this.
sree

Here is an example taken from the ResultSet API Doc's. Note the constant type of "TYPE_SCROLL_SENSITIVE" for the type of ResultSet. Is this what you are using? (I have not tried this, but it is the solution that is put forth in my books and documents.)
       Statement stmt = con.createStatement(
                                      ResultSet.TYPE_SCROLL_SENSITIVE,
                                      ResultSet.CONCUR_UPDATABLE);
       ResultSet rs = stmt.executeQuery("SELECT a, b FROM TABLE2");
       // rs will be scrollable, will not show changes made by others,
       // and will be updatable

Similar Messages

  • Newbie - help needed with array and dictionary objects

    Hi all
    Please see the code below. I've posted this code in another thread however the original issue was resolved and this is now a new issue I'm having although centered around the same code.
    The issue is that I'm populating an array with dictionary objects. each dictionary object has a key and it's value is another array of custom objects.
    I've found that the code runs without error and I end up with my array as I'm expecting however all of the dictionary objects are the same.
    I assume it's something to do with pointers and/or re-using the same objects but i'm new to obj-c and pointers so i am a bit lost.
    Any help again is very much appreciated.
    // Open the database connection and retrieve minimal information for all objects.
    - (void)initializeDatabase {
    NSMutableArray *authorArray = [[NSMutableArray alloc] init];
    self.authors = authorArray;
    [authorArray release];
    // The database is stored in the application bundle.
    NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    NSString *documentsDirectory = [paths objectAtIndex:0];
    NSString *path = [documentsDirectory stringByAppendingPathComponent:@"books.sql"];
    // Open the database. The database was prepared outside the application.
    if (sqlite3_open([path UTF8String], &database) == SQLITE_OK) {
    // Get the primary key for all books.
    const char *sql = "SELECT id, author FROM author";
    sqlite3_stmt *statement;
    // Preparing a statement compiles the SQL query into a byte-code program in the SQLite library.
    // The third parameter is either the length of the SQL string or -1 to read up to the first null terminator.
    if (sqlite3preparev2(database, sql, -1, &statement, NULL) == SQLITE_OK) {
    // We "step" through the results - once for each row.
    // We start with Letter A...we're building an A - Z grouping
    NSString *letter = @"A";
    NSMutableArray *tempauthors = [[NSMutableArray alloc] init];
    while (sqlite3_step(statement) == SQLITE_ROW) {
    author *author = [[author alloc] init];
    author.primaryKey = sqlite3columnint(statement, 0);
    author.title = [NSString stringWithUTF8String:(char *)sqlite3columntext(statement, 0)];
    // FOLLOWING WAS LEFT OVER FROM ORIGINAL COMMENTS IN SQLBooks example....
    // We avoid the alloc-init-autorelease pattern here because we are in a tight loop and
    // autorelease is slightly more expensive than release. This design choice has nothing to do with
    // actual memory management - at the end of this block of code, all the book objects allocated
    // here will be in memory regardless of whether we use autorelease or release, because they are
    // retained by the books array.
    // if the author starts with the Letter we currently have, add it to the temp array
    if ([[author.title substringToIndex:1] compare:letter] == NSOrderedSame){
    [tempauthors addObject:author];
    } // if this is different letter, then we need to deal with that too...
    else {
    // create a dictionary to store the current tempauthors array in...
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    // add the dictionary to our appDelegate-level array
    [authors addObject:tempDictionary];
    // now prepare for the next loop...
    // set the new letter...
    letter = [author.title substringToIndex:1];
    // remove all of the previous authors so we don't duplicate...
    [tempauthors removeAllObjects];
    // add the current author as this was the one that didn't match the Letter and so
    // never went into the previous array...
    [tempauthors addObject:author];
    // release ready for the next loop...
    [author release];
    // clear up the remaining authors that weren't picked up and saved in the "else" statement above...
    if (tempauthors.count > 0){
    NSDictionary *tempDictionary = [NSDictionary dictionaryWithObject:tempauthors forKey:@"authors"];
    [authors addObject:tempDictionary];
    else {
    printf("Failed preparing statement %s
    ", sqlite3_errmsg(database));
    // "Finalize" the statement - releases the resources associated with the statement.
    sqlite3_finalize(statement);
    } else {
    // Even though the open failed, call close to properly clean up resources.
    sqlite3_close(database);
    NSAssert1(0, @"Failed to open database with message '%s'.", sqlite3_errmsg(database));
    // Additional error handling, as appropriate...
    Message was edited by: dotnetter

    Ok, so I know what the issue is now...I just don't know enough to be able to resolve it!
    it's the tempAuthors objects.
    It's an NSMutableArray which is create on the line before the start of the WHILE loop.
    Having looked through the debugger, I can see that each dictionary object is created (with different codes which I assume are memory addresses) so all is well there. However, on each iteration of the loop in the middle there is an IF...ELSE... statement which in the ELSE section is clearing all objects from the tempAuthors array and beginning to repopulate it again.
    Looking at the containing dictionary objects in the debugger I can see that the tempAuthors object that each contains has the same code (again, I'm assuming this is a memory address) - so if I understand correctly, it's the same object...I assumed that when I created the dictionary using the dictionWithObject call that I would be passing in a copy of the object, but it's referencing back to the object which I then go on to change.
    Assuming the above is correct, I've tried several "stabs in the dark" at fixing it.
    I've tried relasing the tempAuthors object within the ELSE and initialising it again via an alloc...init - but this didn't work and again looking through the debugger it looks as though it was confused as to which object it was supposed to be using on the following iteration of the WHILE loop (it tried to access the released object).
    Having read a little more about memory management can someone tell me if I'm correct in saying that the above is because the tempAuthors object is declare outside the scope of the WHILE loop yet I then try to re-instantiate it within the loop (does that make sense???).
    Sorry for the long post...the more I can understand the process the less I can hopefully stop relying on others for help so much.
    I am continuing to read up on memory management etc but just not there yet.
    Regards
    Wayne

  • Regarding Array and ArrayList

    Hi all,
    if any body knows the difference between Array and Array List Conceptually tell me the differences..
    Thanks ,
    Naveen

    An array is a less dynamic structure than an ArrayList. An array gets a fixed size once it's created. It's memory is allocated upon creation, generally these are sequential memory locations.
    An ArrayList provides the same features as an Array: you can acces the contents by index. It add the features of a List to it: getting the head, traversing contents, inserting, appending... It also can grow in size dynamically. This is done by giving each element in an ArrayList a reference to the next element. This allows the elements to be stored throughout the available memory.

  • Some help needed regarding Files and URLs on a server

    I don't get it - my applet works in a local directory, but not on a server. This has to do with the loading of files (I load an array of images to use, but when I attempt to use that array, it comes up with the error ArrayIndexOutOfBounds), but I can't understand what the problem is...
    I have a code that loads files (using File objects) from the current directory (a .jar file) into the program. I do not simply type in the file names - I set it so that the program searches for them based on a prefix in the file name. This works fine on my computer, and I never navigate to files outside of the .jar file. Why might this have a problem on a server? Would URL objects be more appropriate?
    Note: I alter the file base String in this way before loading it (this stands for the current directory)
    fileBase = applet.codeBase.toString().replace('\\', '/');codeBase is simply the applet's codeBase() method put into a URL variable. The replace statement is there so that there are no backslashes. And this works perfectly on my computer. Any help? Would it work if I used a URL instead? If so, how do I perform a search function with a URL (so that all the filenames within a certain directory are returned as Strings)?

    Thanks for the info, it helps a lot. You say there is no "practical" way to search for a file under a URL path. What I am trying to do is load a file that begins with a particular prefix. (eg. I wish to load a file called "funnyImage0011204924." However, the numbers after the prefix "funnyImage" are variable, and might require change in the future. Is it possible to load any file with the prefix "funnyImage," using URL methods? Would I need to create a new class? Is this impossible?)
    Please remember that I do not plan to go outside the .jar file, so there is no point in trying to get around server permissions and all that if it is unnecessary.

  • Little help needed regarding http and https

    Hi,
    I maintain a website for my organization. Recently, for a login page, I started using HTTPS. It works fine with HTTPS.
    The problem I face is : When a user goes to login page, he sees the login page via HTTPS. Now, if user doesn't submit the login form but chooses to browse some other link on the same page, that page will still be shown using HTTPS because links are relative. This increases unnecessary HTTPS traffic on the server.
    I need a solution that can help me to change protocol back to HTTP if the user doesn't submit login form. I have written small piece of java script that can check at the time of leaving the page. If submit button wasn't pressed, it should change the protocol back to HTTP. I have played around window.location object trying to change it's href property. But, no luck yet. Please help me.
    window.onunload = function()
    // if submit button wasn't pressed, change the protocol back to HTTP          
              if (!submitPressed)
                        window.location.protocol="http:";
                        alert(windows.location.href);
                     window.location.port = "80";
            }Please let me know if you know about some simple solution.
    Edited by: Di_Ke on Nov 13, 2007 2:12 PM
    Edited by: Di_Ke on Nov 13, 2007 2:14 PM

    Just to clarify, before anyone can answer: Do you have access to the web server settings, and are you looking for a server side solution for this problem? If the answer to any of those two question is no, and you are just looking for a javascript help, this forums is not the best source for answers.

  • Help needed regarding JDeveloper and ADF

    Hi All,
    I am new to ADF customization in JDeveloper. Can any of the experts here, guide me how to start and get myself expertise in ADF. Actually i have been doing some experiments like creating trains,connecting to DB etc., from few days back. But the main thing is i could'nt able to figure out the usage of each and every component. So try to help me.
    Thanks in advance.

    Hi,
    check
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html - All samples
    http://download.oracle.com/docs/cd/E21764_01/apirefs.1111/e12419/toc.htm - new tag Doc 11.1.1.5
    http://download.oracle.com/docs/cd/E18196_01/11.1.2.0.0/main_11.1.2.0.0.html - new sample 11.1.2.0

  • Help needed regarding buttons and action listeners!

    Hey,
    Im designing an applet and im trying to create it so that when a button is pressed a new Draw object is drawn, I have read up about action listeners but im not totally sure where they need to be inserted
    Ive posted my code below so hopefully someone out there wll be able to see what im working with!
    Thank you in advance
    public class ImageWithMulti extends Applet {
        Image image;
        public void init () {
            image = getImage(getDocumentBase(),
                getParameter("Channel"));
        public void paint(Graphics g) {
            g.drawImage(image, 0, 0, this);
            drawMultiDown1
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);   //2nd number changes left sided position up or down
            drawMultiUp1
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
            drawMultiUp2
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
            drawMultiDown2
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white); 
            drawMultiUp3
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);   
           drawMultiDown3
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
           drawMultiUp4
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
           drawMultiDown4
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
           drawMultiUp5
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);

    hi,
    i've modify your code. but i've commented your some original code because i was getting error...
    please check the code...
    import java.awt.event.*;
    import java.applet.*;
    import java.awt.*;
      <applet code="ImageWithMulti.class" width=100 height=140></applet>
    public class ImageWithMulti extends Applet implements ActionListener {
        Image image;
        Button btnClick = null;
        public void init () {
            /*image = getImage(getDocumentBase(),
                getParameter("Channel"));*/
              btnClick = new Button("Click");
              add(btnClick);
              btnClick.addActionListener(this);
        public void paint(Graphics g) {
            g.drawImage(image, 0, 0, this);
           /* drawMultiDown1
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);   //2nd number changes left sided position up or down
            drawMultiUp1
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
            drawMultiUp2
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
            drawMultiDown2
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white); 
            drawMultiUp3
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);   
           drawMultiDown3
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
           drawMultiUp4
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
           drawMultiDown4
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);
           drawMultiUp5
        (g, 0, 0, getSize().width, getSize().height, 25, new Color(0).white);*/
         public void actionPerformed(ActionEvent ae){
              if(ae.getSource() == btnClick){
                   System.out.println("Hey");
    }dhaval..

  • Need help with an array function

    I'm using the array index function and i would like to be able to control what elements go out on it.  For example, if i wanted only the first element to go out, i don't want the second element to send out zero.  Is there any way i can control what elements leave the array index function.  I also don't understand what the index inputs do on that function either.  If anyone has any advice on the application or can modify it in any way, please help.
    Attachments:
    Array and for loop.vi ‏1190 KB

    The index inputs determine what elements are retrieved. For example of you would wire a 10 and a 20 to your two index inputs, you would bet element #10 and element #20 of your array. You can resize it to get any desired number of elements.
    If you don't wire the index inputs, you'll get the first two elements.
    If you only wire the top index input (e.g a 10), you'll get element #10 and #11.
    LabVIEW Champion . Do more with less code and in less time .

  • ARRAY and records at multiple level ? please help

    Hi experts!!
    I am struck up with a problem. If u can please help me.
    I need a structure of this type.
    create type GRADE as object(
    grade varchar2(30)
    / -- works fine , creates
    create type GRADE_ARRAY as VARRAY(10) of GRADE;
    / -- works fine and creates
    create type SPECIES as object
    Species_number number,
    array_of_grade GRADE_ARRAY
    / works fine
    create type SPECIES_ARRAY as VARRAY(20) of SPECIES;
    -- error comes here.. Can not have multiple level..type error
    and so can not go ahead. In fect I wanted to use next level also. like this.
    The next command remains my dream only then because I could not create the SPECIES ARRAY it self..
    create type TIMBER as object
    timber_mark varchar2(6),
    no_species number,
    array_of_species(20) SPECIES_ARRAY
    the problem is for multiple level ARRAY AND RECORD/object combination..
    I tried with OBJECT AND VARRAY it does only for one level.. not even two level.
    my Mail ID:
    [email protected]
    Thanks and Regards..
    Virendra chauhan

    I think multi-level collections was first implemented in 9.2. You failed to mention what version of the DB you are using.

  • I have just getting a new phone and I have forgot my password an Apple ID what I made new for the new phone now I cannot get on it because asking for id and password what should I do help plz thank u

    I have just getting a new phone and I have forgot my password an Apple ID what I made new for the new phone now I cannot get on it because asking for id and password what should I do help plz thank u

    Try
    https://iforgot.apple.com

  • I lost my phone and i got an unlocked 4s from my gf she used it before an its still connected to her icloud is there a way i can restore my icloud back up to replace hers without messing up the unlock also my latest backup isnt showing on my pc help plz!!

    i lost my phone and i got an unlocked 4s from my gf she used it before an its still connected to her icloud is there a way i can restore my icloud back up to replace hers without messing up the unlock also my latest backup isnt showing on my pc help plz!!

    Please please help me, if you know how.

  • Help plz so my gf said she block me and we txt back to back but later on i sent her a messages and it said it was read so am I blocked  a

    help plz so my gf said she block me and we txt back to back but later on i sent her a messages and it said it was read so am I blocked 

    The proper way to close Firefox is through the File menu "Exit" or the equivalent with the Firefox button.
    More detail in item '''#38 Firefox already running '''
    of
    [http://dmcritchie.mvps.org/firefox/firefox-problems.htm#fx4interface Fix Firefox 4.0 toolbar user interface, problems (Make Firefox 4.0 look like 3.6) (#fx4interface)]
    Firefox already running, to properly shutdown Firefox when closing the last window use File → Exit/Quit (or Firefox button → Exit). Closing Firefox with the [X] in the upper right corner closes the window ("Ctrl+W") but that does not necessarily close Firefox if it has subtasks running. If you want to close and reopen Firefox use the "Restart" within Add-ons if you made a change requiring a restart, or install "[https://addons.mozilla.org/firefox/addon/restartless-restart/ Restartless Restart]" ("Ctrl+Alt+R") which will allow you to take Firefox down and restart without having to check the Windows Task Manager to see if Firefox first actually ended. [http://kb.mozillazine.org/Firefox_hangs Firefox hangs]

  • I bought an ipod in 2006 and used it only for a few days, and i lost it when it fell two times from my hand and it wasn`t working, help me regarding this.

    i bought an ipod in 2006 and used it only for a few days, and i lost it when it fell two times from my hand and it wasn`t working, help me regarding this.
    REGARDS
    RISHABH AULIYA

    Apple - Support - iPod - Repair pricing - http://www.apple.com/support/ipod/service/prices/
    ipod repair options - https://discussions.apple.com/thread/3900047 and https://discussions.apple.com/message/18867033
    Service Answer Center - iPod - http://support.apple.com/kb/index?page=servicefaq&geo=US&product=ipod  <-- enter correct country once on page.

  • I forgot my password, and i want to unlock it without losing my data, can anyone help plz???

    i forgot my password, and i want to unlock it without losing my data, can anyone help plz???

    You can't. It is a good security feature. You have to connect the iPod to yur computer and restore via iTunes.

  • How to Read and Write .XML datas   (HELP Plz...)

    hai everybody
    how to read and write xml datas... plz give clean and simple example..
    bcoz me want to produce such type of module...
    if any one help me .. thats the only way me laid in software ladder
    plz....
    thank u in advance

    thank u for giving idiot..
    but before posting i search in google also..
    but i cant get what me expect..
    thus i posted...
    then who is ................?
    sorry javacoder01
    // plz help me
    Message was edited by:
    drvijayy2k2

Maybe you are looking for

  • Sale order delivery and billing blocked

    Hi sap sd gurus I have a problem after creating a sale order , the one line item in sale order showing status of delivery blocked and billing blocked , now i am unable to post delivery and billing when i see in schedule line item order qty and confir

  • Recovering Data from a disabled/passcoded IPhone

    My Aunt has had an IPhone for quite some time and she has a lot of data on it. Contacts, photos and so forth. She recently accidentally passcoded the phone and does not know the passcode, so it is more or less disabled now. Now the big problem, she l

  • Problem in uploading material master data using BDC?

    Hi all, I am using  BDC call transaction method to upload material data. Here i am facing a problem that a value in the flat file is going to the wrong screen field . But my recording done properly. In recording, after entering the data in the view B

  • How to calculate the number of sent/received emails of a certain domain

    Thank you for what you have helped me with! How to calculate the number of sent/received emails of a certain domain in a certain period? It is Messaging Server 5.2, Directory Server 4.2. Is there a log option for this? Thank you.

  • Ipod is nothing more than a very expensive toy

    I just bought my ipod touch. Some of the features are quite good. Also in writing this note, I am very new to the ipod. If there is a feature I complains about, it is because I don't know it exists. I have found the documentation on the ipod horribly