Initializing Vector with ResultSet(TO SLOW!)

Hi
Im creating a JTable from two Vectors. I need to initialize
the one vector from a resultset. This is way to slow for large result sets. Heres my loop:
private Vector getData(int columns[]) throws Exception
     rows = new Vector(queue.count);
     while (res.next())     
         Vector newRow = new Vector(columns.length);
         for (int i = 0; i < columns.length;i++)  
           newRow.addElement(res.getString(columns));
rows.addElement(newRow);
return rows;
Any Ideas to speed this up a bit.
Thanks!

private Vector getData(int columns[]) throws
Exception
rows = new Vector(queue.count);
while (res.next())
Vector newRow = new Vector(columns.length);
for (int i = 0; i < columns.length;i++)
newRow.addElement(res.getString(columns));
rows.addElement(newRow);
return rows;
Any Ideas to speed this up a bit.
Thanks!
I tested your code using String[][] rows (instead of Vector rows) hoping using arrays will make it faster. But it did not. What really did improve the performance was declaring and alocating memory for String[][] rows before calling the function. That is to say, the most time is spent on rows = new String[ROWS][COLS]. If you your conditions allow you to use String[][] rows instead of Vector rows and allocate memory for String[][] rows before calling your method getData(), then, in my opinion, it will improve the performance.
Cheers!

Similar Messages

  • Initializing Vector with ResultSet(too Slow!)

    Hi
    I'm createing a JTable with two Vectors. Im am initializing the Vectors in a while loop, but it is way to slow with large ResultSets.
    Does anyone know how I can speed this process up?
    Thanks!

    Heres the full method Ive removed some of hte code in the for loop. But that makes no difference to the speed
    private Vector getData(int columns[]) throws Exception
         rows = new Vector(queue.count);
         while (res.next())
                 Vector newRow = new Vector(columns.length);
              for (int i = 0; i < columns.length; i++)
                 newRow.addElement(res.getString(columns));     
    rows.addElement(newRow);
    return rows;

  • Initializing Vectors with objects.

    Hi all,
    I am investigating a problem and have narrowed down to a section of code where the Vector.get() method returns an empty string instead of null when the key queried doesn�t exist. I know I can alter the code to check for null or empty string but I wanted to find out why?
    I am not sure if initializing a Vector variable with an existing object is the cause� Here is a line from the code:
    Vector result = oracleWrapper.getCodeList (regionCode); //This call returns a vector.In test I ran this code a million times but couldn�t recreate it� but in production, after a few days (since the server bounce (JRun 4x)) of normal behaviour, it just starts returning empty string instead of null for keys that don�t exist in the Vector! Restarting the server is the solution for now!
    What I want to find out:
    1. Is initializing Vectors like in the snippet above fine?
    2. Are there any known issues similar to this scenario?
    3. Is call to a constructor explicitly required to guarantee its integrity?
    Thanks a mill,
    Jay

    True and I have already removed the Vector from my list of suspects because this problem only happens after a few days of normal functioning and the vector still contains an incomplete string when the error starts. I am on the look for statements that may be resulting in memory leaks and temporarily have a Properties object in my list of suspects along with a few StringBuffers.
    The code has a statement Properties props = null; and then after a few lines a value from a Vector object is put into it!
    props= (Properties) result.elementAt(idx);I have load tested it but cant get it to break!
    I have spent way too long on this and may be rewriting it would have been quicker! But can�t :(
    I am soo stuck.

  • Slow initial association with WRT54GS w/WRE54G

    I have 2 laptops and both are having problems with initial association with the WRT54GS and WRE54G.
    I had some initial problems with the WRE54G but have fallen back to a default install with no security for troubleshooting.
    However even with this default install, both laptops will do the initial attempt to associate with my SID, fail to acquire IP, and then grab an IP about 2 minutes or so after failure.
    Does anyone have an idea as to what would cause this and how do I speed up the acquisition of a valid IP?
    Thanks,
    GimmeFive

    I'm new here, too, and looking for solution to exact same problem. Starts at 54 mbps and then very quickly drops down to 11 then 2 then 1!  I've done no updates or changes since buying it.  I have V7.2.  My very old D-Link 524 worked better than this!  Sure hope someone has a solution. Keep in mind that I don't know what all the special language is, and since I work 60 hrs per week at 3 businesses, don't have time for much more than I'm doing.  So hope you explain VERY clearly what needs to be done if you have a solution.  Thanks so much for any help to any of us... : )

  • Populating an existing vector from ResultSet

    I want to populate a JTable's Table Model's Vector with data from a ResultSet. The code that I have
    seen follows the general pattern of the code below, from "The JDBC:�Practical Guide for Java Programmers"
    It creates a new Vector and fills the data in.
             public void presentResultSet(ResultSet rs)
         throws SQLException {
         Vector dataVector = new Vector();     //     ----------------------------- create an NEW Vector
         if (!rs.next())
             JOptionPane.showMessageDialog(null,"No records for customer");
         else {
             do {
              Vector rowVector = new Vector();
              rowVector.addElement(rs.getString("Title"));
              rowVector.addElement(rs.getString("Type"));
              dataVector.addElement(rowVector);
              } while (rs.next());
         Vector headVector = new Vector(2);
         headVector.addElement("Title");
         headVector.addElement("Type");
         dataTable = new JTable(dataVector, headVector);
         dataTableScrollPane.setViewportView(dataTable);
         I want to populate an existing vector which already exists, and has several methods attached to it.
    Please look at the code below, and tell me if it is on the right track, or what changes need to be made.
         //     ------------------------------------------------- To populate an existing (tableModel) vector:
         int rows = 10;
         int cols = 10;
         Table2Model t2Model = new Table2Model();
         while (rs.next()) {
              for ( int r = 0; r < rows; r++ ) {                         
                   for ( int c = 0; c < cols; c++ ) { // visibleColumns                    
                        ( ( Vector )t2Model.elementAt( r ) ).setElementAt( rs.getString( c+1 ), c );
         Many thanks in advance

    Looks like you are

  • I have a 2008 iMac 21.5" 10.6.8 Snow Leopard with 4.1.3 VMWare and windows 7.Mountain Lion initially refused to down load as I had back up on the HD. this was removed and installation was accepted but froze in the initial stages with 33 mins to go.

    I have a 2008 iMac 21.5" using 10.6.8 Snow Leopard with VM Ware 4.1.3 supporting Windows 7. Initially ML OSX refused to install due to Back up on HD which I removed to trash.It then proceeded but froze up in the initial stages with 33 mins remaining. I was lucky enough to quit and restart using 10.6.8. With all the problems on this chat line, it appears it may be best to leave Mountain Lion well alone, and cut losses rather than tempt fate.Has anybody anything positive to say or help with?

    Welcome to Apple Communities
    1. Open Disk Utility and repair permissions
    2. Open Finder, go to your user's folder > Library > Caches and delete everything
    3. Verify disk
    4. See if your apps are compatible with OS X 10.8 > http://www.roaringapps.com
    You can also do a backup and create a DVD or USB drive to install OS X > http://arstechnica.com/apple/2012/07/how-to-create-a-bootable-backup-mountain-li on-install-disk/ When you start in 10.8 installer, open Disk Utility, select your volume and erase the drive, and install

  • How do I fix a initializing problem with my macbook pro? I only get to the blank screen with the apple logo and the "processing something"sign... it just doesn't start the system....

    How do I fix a initializing problem with my macbook pro? I only get to the blank screen with the apple logo and the "processing something" sign... it just doesn't start the system....
    Please help
    Marcelo

    If there is no loading bar, it's usually a problem with a third party kext file in OS X itself.
    You can press the power button down to force a hardware shutdown, then reboot holding the shift key down on a wired or built in keyboard, this will disable them and you go around and update your third party software.
    Gray, Blue or White screen at boot, w/spinner/progress bar
    Also take this time to backup your users files off the machine if possible.
    Most commonly used backup methods
    Sometime that won't work and you need to do more
    ..Step by Step to fix your Mac

  • Problem with ResultSet in a loop

    hi,
    i have a probleme with ResultSet when, my code is bellow
    ResultSet rs = stmt.executeQuery(sql);
    sql="SELECT NAME FROM prestationtemp";
    rs = stmt.executeQuery(sql);
    String sqlDel="";
    while (rs.next())
    sqlDel="Delete from prestation where NAME="+rs.getString("NAME");
    stmt.executeQuery(sqlDel);
    the problem is that the loop iterate just once like if there is just one record, and if I remove stmt.executeQuery(sqlDel); from the loop it iterate normaly.
    thanks in advance.

    you will need to use 2 Statments e.g.
    Statement stmt1 = connection.createStatement();
    Statement stmt2 = connection.createStatement();
    ResultSet rs = stmt.executeQuery(sql);
    sql="SELECT NAME FROM prestationtemp";
    rs = stmt1.executeQuery(sql);
    String sqlDel="";
    while (rs.next())
    sqlDel="Delete from prestation where NAME="+rs.getString("NAME");
    stmt2.executeQuery(sqlDel);
    } When you reuse a Statement, any resultsets previously created are automatically closed.
    Looking at your code, it seems that you only need 1 SQL call:
    Delete from prestation where NAME in (SELECT NAME FROM prestationtemp)
    Much more efficient!

  • My magic mouse behaves erratically with intermittent problems - slows down, right click doesn't work, disconnects for a few seconds then reconnects. Anyone suggest what I could do to fix this?

    My magic mouse behaves erratically with intermittent problems - slows down, right click doesn't work, disconnects for a few seconds then reconnects. Anyone suggest what I could do to fix this?

    I just figured out the print quality issue for my wife with her new iMac and new printer.
    She replaced both at once and she couldn't understand why her Artisan 730 was lower quality then her Epson R280 when they had the same specs.
    Turns out the newer printer had the option to connect via wifi which we used during setup.
    The driver options are completely different depending on how you connect.
    Once I connected via USB the correct options were available and the print quality was better.
    Looking at the R2400 it dies not have wifi, but while researching the problem for my wife someone esle was having an issue updating to the latest printer driver.
    If you go into the print utility from the Printer and Scanner system preference and under the general tab you should have driver 5.5.
    One user had to delete the old printer driver before Software Update loaded the newer printer driver.
    https://discussions.apple.com/message/15947486#15947486
    On my MacBook Pro (w Snow Leopard) I always had to reconnect my wifi at home when it woke up. I upgraded my router from an old Netgear to a newer N D-Link and stopped having to do that.
    I would be surprised you would have that problem with an Airport Extreme, you might check to see if there is a firmware update for it.

  • Error in JMS receiver adapter: "Error creating initial context with environment"

    Hello,
    I have some trouble with a JMS receiver adapter (access to JMS-provider with JNDI).
    The message in adapter monitoring is:
    A channel error occurred. Detailed error (if any) :
    com.sap.aii.adapter.jms.api.connector.ConnectorException: Fatal Error looking up connection factoryJMSQueueConnectionFactory, for profile: ConnectionProfile of channel: CC_JMS_RCV_XLIMI00001on node: 503473150 having object id: 5b424f2f79b6350ca636ab35d528cfdd:
    ConnectorException: Error creating initial context with environment: java.naming.provider.url=wcsefdev.example.com:9064; java.naming.factory.initial=com.ibm.websphere.naming.WsnInitialContextFactory; for profile: ConnectionProfile of channel:
    CC_JMS_RCV_XLIMI00001on node: 503473150 having object id: 5b424f2f79b6350ca636ab35d528cfdd: javax.naming.NoInitialContextException:
    Cannot instantiate class: com.ibm.websphere.naming.WsnInitialContextFactory<br> at com.sap.aii.adapter.jms.core.connector.JndiConnectorImpl.createConnectionFactory
    (JndiConnectorImpl.java:152)<br> ....
    Message processing failed. Cause:
    com.sap.aii.adapter.jms.core.fsm.DFA$InvalidTransitionException: No transition found from state: ERROR, on event: process_commence for DFA: CC_JMS_RCV_XLIMI00001:5b424f2f79b6350ca636ab35d528cfdd
    The third party assured me that the specified JNDI parameters are right and everything is configured on their site, so it should work...
    Might there be a problem with the JMS drivers?
    Regards,
    Marcus

    Hi Marcus,
    Have a look at below thread
    Connecting to PI 7.11 JMS Queue from other PI 7.11 Server

  • Error creating initial context with environment

    Hi,
    Currently we are working on a scenarios, where we need to integrate XI and webmethods using JMS.
    It was working fine. But recently they have restarted the webmethods server. After that we re getting an error message like,
    In Adapter Monitoring:
    Channel error occurred; detailed error description: com.sap.aii.adapter.jms.api.connector.ConnectorException: Error creating initial context with environment: {java.naming.provider.url=server:port, java.naming.factory.initial=com.sap.engine.services.jndi.InitialContextFactoryImpl, java.naming.security.principal=XYZ, java.naming.security.credentials=ABC}for profile: ConnectionProfile of channel: CC_RCV_JMS_INon node: 3010950 having object id: ABCXYZ: NamingException: Error getting the server-side naming service functionality during getInitialContext operation.
    at com.sap.aii.adapter.jms.core.connector.JndiConnectorImpl.createInitialContext(JndiConnectorImpl.java:66)
    In RWB
    MP: Exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: No transition found from state: STARTING, on event: process_commence for DFA: C_RCV_JMS_IN:e4413a5265a436459e271d5e0dd4859b
    Can one please tell me what the problem is?
    Thanks in advance.
    Regards,
    Prasad Babu.

    Hi,
    Check this link looks like same problem
    Re: file to JMS(for MQ series)
    Thanks
    Vikranth

  • Why is BT wifi with fon so slow?

    Why is my BT wifi with fon so slow? Normally it works ok and is fast but then it suddenly starts to drag and nothing ever loads, the connection always dropping and it says "Limited Access" with a little yellow triangle.  This happens mainly in evenings and afternoons.

    terrorangel99 wrote:
    Why is my BT wifi with fon so slow? Normally it works ok and is fast but then it suddenly starts to drag and nothing ever loads, the connection always dropping and it says "Limited Access" with a little yellow triangle.  This happens mainly in evenings and afternoons.
    Its most likely because whoever owns the broadband connection, is using it a lot. They get priority over any BT Wifi connection, so you will get a very slow connection, or one which drops.
    There are some useful help pages here, for BT Broadband customers only, on my personal website.
    BT Broadband customers - help with broadband, WiFi, networking, e-mail and phones.

  • How to create Vector with reference to Collection

    hello experts,
    can someone let me know how to create vector with reference to Collection interface.
    Collection is an interface. and we cant create an instance of it. i'm not clear of what to pass in that constructor.
    Vector v = new Vector (Collection c);
    what are the possible objects of 'c'
    post some example code please.
    thanks

    Ever heard of reading the javadocs?
    "Collection is an interface. and we cant create an instance of it." - you don't understand interfaces, then.
    // I certainly can create a Collection - here's one
    Collection c = new ArrayList();
    // Now I'll add some Strings to my Collection.
    c.add("foo");
    c.add("bar");
    c.add("baz");
    // Now I'll make a Vector out of it.
    Vector v = new Vector(c);%

  • Can i save a vector with gradient mesh as isolated .PNG?

    Hi,
    Can i save a vector with gradient mesh as isolated .PNG?
    It has some effects, so if i'm taking it out from the blue background it becomes darker.
    Any advice? I need it isolated png for using it in an iOS app.
    Many thanks

    I am using Illustrator CS6, on Mac.
    I can't copy and paste the "cloud" into a new document to save it, because it looses the effect of those filters (since the background is no longer behind it).
    Sorry if im not explaining it right, i'm a beginner in illustrator.  Can i group both the "cloud" and the blue background, to get just one shape: the realistic white cloud?
    P.S: i can make a link with the .esp file of the clouds, if it helps.

  • Initial load with LOBs

    Hi, i'm trying to do an inital load and I keep getting errors like these:
    ERROR OGG-01192 Oracle GoldenGate Capture for Oracle, ext1.prm: Trying to use RMTTASK on data types which may be written as LOB chunks (Table: 'TESTDB.BLOBTABLE').
    ERROR OGG-01668 Oracle GoldenGate Capture for Oracle, ext1.prm: PROCESS ABENDING.
    The table looks like this:
    COLUMN_NAME|DATA_TYPE|NULLABLE|DATA_DEFAULT|COLUMN_ID|COMMENTS
    UUID     VARCHAR2(32 BYTE)     No          1     
    DESCRIPTION     VARCHAR2(2000 BYTE)     Yes          2     
    CONTENT     BLOB     Yes          3     
    I've checked and the source database does contain data in the blobtable and both databases have the same tables, so now I have no idea what can be wrong? =/

    For initial loads with LOBs, use a RMTFILE and a normal replicat. There are a number of things that are not supported with "RmtTask". A "rmtfile" is basically the same format as a 'rmttrail' file, but is specifically for initial loads or other "captured" data that is not a continuous stream. And make sure you do have a newer build of GG (either v11 or a latest 10.4 from the support site).
    The 'extract' would look something like this:
    ggsci> add extract e1aa, sourceIsTable
    ggsci> edit param e1aa
    extract e1aa
    userid ggs, password ggs
    -- either local or remote
    -- extFile dirdat/aa, maxFiles 999999, megabytes 100
    rmtFile dirdat/aa, maxFiles 999999, megabytes 100
    Table myschema1.*;
    Table myschema2.*;
    Then on the target, use a normal 'replicat' to read the "files".
    Note that if the source and target are both oracle, this is not the most efficient way to instantiate the target. Using export/import or backup/restore (or any other mechanism) would usually be preferable.

Maybe you are looking for