Problems with the resultset

hello
i have a servlet that connects to a db. Data is passed back in the resultset. But only for one of my columns(if i specify it in my select statement)- i want the resultset to pass back the column that the user has selected(this is via a variable called 'type')!
But i get an exception of type:
java.lang.ArrayIndexOutofBoundsException
Heres my code:
query = "select '"+type+"' from caravan_charges where..........
Resultset result = stmt.executeQuery(query);
int count = 0;
while(result.next()) {
count += result.getInt(1);
can anyone help!!!

check the variable query and check the SQL statement. But the error relate to an array most probably where the code result.getInt(1);. Check my code below. by getting the column count will surely avoid the outofbounds array error.
SQLResult = StatementSQL.executeQuery(sql);
if (!SQLResult.next()) {
     JOptionPane.showMessageDialog(null, "No rows retrieved.\nPlease check SQL script.");
     JTable emptyTable = new JTable(dataVector, headerVector);
     resultTableScroller.setViewportView(emptyTable);
else {
     ResultSetMetaData mdSQL = SQLResult.getMetaData();
     int colCount = mdSQL.getColumnCount();
     //get column names here
     for (int i = 1; i <= colCount; i++) {
          String colName = mdSQL.getColumnName(i);
          colName.trim();
          headerVector.addElement(colName);
     do {
          Vector rowVector = new Vector();
          for (int i = 1; i <= colCount; i++) {
               String colName = mdSQL.getColumnName(i);
               colName.trim();
               rowVector.addElement(SQLResult.getString(colName));
          dataVector.addElement(rowVector);
     } while (SQLResult.next());

Similar Messages

  • [Execute SQL Task] Error: Executing the query "DECLARE_@XMLA nvarchar(3000) ,__@DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly,

    Hi
    DECLARE @XMLA nvarchar(3000)
    , @DateSerial nvarchar(35);
    -- Change date to format YYYYMMDDHHMMSS
    SET @DateSerial = CAST(GETDATE() AS DATE);
    --SELECT @DateSerial
    Set @XMLA = 
    N' <Batch xmlns="http://schemas.microsoft.com/analysis services/2003/engine">
     <ErrorConfiguration xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2"
    xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2" xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200"
    xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200">
    <KeyErrorLimit>-1</KeyErrorLimit>
    <KeyNotFound>IgnoreError</KeyNotFound>
    <NullKeyNotAllowed>IgnoreError</NullKeyNotAllowed>
     </ErrorConfiguration>
     <Parallel>
    <Process xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ddl2="http://schemas.microsoft.com/analysisservices/2003/engine/2" xmlns:ddl2_2="http://schemas.microsoft.com/analysisservices/2003/engine/2/2"
    xmlns:ddl100_100="http://schemas.microsoft.com/analysisservices/2008/engine/100/100" xmlns:ddl200="http://schemas.microsoft.com/analysisservices/2010/engine/200" xmlns:ddl200_200="http://schemas.microsoft.com/analysisservices/2010/engine/200/200"
    xmlns:ddl300="http://schemas.microsoft.com/analysisservices/2011/engine/300" xmlns:ddl300_300="http://schemas.microsoft.com/analysisservices/2011/engine/300/300">
     <Object>
     <DatabaseID>MultidimensionalProject5</DatabaseID>
     <CubeID>giri</CubeID>
     <MeasureGroupID>Fact Internet Sales</MeasureGroupID>
     </Object>
     <Type>ProcessFull</Type>
     <WriteBackTableCreation>UseExisting</WriteBackTableCreation>
     </Process>
      </Parallel>
    </Batch>';
    EXEC (@XMLA) At SHALL-PCAdventureWorksDw ;
     iam executive the    query when iam getting below error.
      [Execute SQL Task] Error: Executing the query "DECLARE
    @XMLA nvarchar(3000)
    , @DateSerial nvarch..." failed with the following error: "Incorrect syntax near '-'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set
    correctly, or connection not established correctly. 
     how to solve this error;
     please help me

    What are you trying to do? What sort of data source is  SHALL-PCAdventureWorksDw?
    When you use EXEC() AT, I would execpt to see an SQL string to be passed to EXEC(), but you are passing an XML string????
    If you explain why you think this would work in the first place, maybe we can help you.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • : "Invalid object name '#Temp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

     Hi   .
        I was creating the  pass the values t in temp tables  though s sis package vs2012 .
      First I was taken on executive SQL TASK.
     IN EXCUTIVE SQL TASK  . I was write the stored proce:
    Sp;
    reate  procedure  USP_GETEMP2333
    AS
    begin
    Select  eid,ename,dept,salary from emp
    end;
    create table #temp(eid int,ename varchar(20),dept varchar(20),salary int)
      insert into #temp
       exec USP_GETMP02333
       go.
     It was executive correctly.
     I was taken another sequence container. In the sequence container iam creating one   executive  sql
    In 2<sup>nd</sup> excutive sql task: sql statements is
    if object_id('emp_fact_sal') is not null
     drop table emp_fact_sal
    select eid,ename as emp_name,sal_bar=
    case when salary<=5000 then 'l'
    when salary >5000 and salary<=7000 then 'm'
    else
    'h'
    end
    into emp_fact_sal from #temp.
     and one falt flies  it was taken to designation .
     iam changing  all  connection properties:
     in oldeb connection:
    in excutive sal task properties .
    delay validation is true,
    and retain connection maner is also true,
    and package mode is 64 bit is false.
     But iwas excutive in 2<sup>nd</sup> excutive ql task .
    Iam getting this type of errors,
                    [Execute SQL Task] Error: Executing the query " if object_id('emp_fact_sal') is not null
     drop ta..." failed with the following error: "Invalid object name '#Temp'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established
    correctly.
     Please help me

    Arthur suggestion works but you shouldnt even be doing this on a SQL Task.
    Use a data flow task. You'll have better control over the data that is being transfered and get better performance because no staging table will be used.
    Just because there are clouds in the sky it doesn't mean it isn't blue. But someone will come and argue that in addition to clouds, birds, airplanes, pollution, sunsets, daltonism and nuclear bombs, all adding different colours to the sky, this
    is an undocumented behavior and should not be relied upon.

  • Problem with the input file format to be stored in database

    Hi,
    I am facing some problem with the input format. I am using the table name as data.employee. But i could not able to process the message forward. I am getting this error,
    com.ibm.db2.jcc.c.SqlException: java.sql.Connection.close() requested while a transaction is in progress on the connection.The transaction remains active, and the connection cannot be closed.
    Can you please help me prposing a solution for this format.
    Thanks,
    SOorya

    I think you are missing out the COMMIT operation.
    At the DB2 end before closing the connection if you do a 'COMMIT' then this may remove your error.
    i.e. after you close the Resultset>close the statement object> perform 'COMMIT' operation--> then close the connection.
    Also refer :-
    http://www.dbforums.com/archive/index.php/t-976407.html
    http://www.dbforums.com/showthread.php?t=1628183
    I hope this will help you.
    Thanks,
    Vijaya

  • I just order 8 calendars from iPhoto and they came to me fine. Now I need to order two more but when I go thru the process I get a message  saying:unable to assemble calendar. There is a probleme with the photo with the file name"(Null)"   more........ .

    Would someone be able to explain to me the following issue with Iphoto?
    I ordered 8 same calendars for my soccer team and received them fine. Although a couple of pictures on it are a little off (out of focus). I need to order two more of the same calendars but when I go thru the process ireceive an error message saying:
    "Unable to to assemble  calendar" There is a problem with the photo with the file name "(Null)" The full resolution version of this photo either cannot be located or is corrupt. Please replace this photo or delete it from your calendar.
    How can  I fine this "corrupt" photo? How did it go thru with the first batch of calendars but won't go thru now?
    Thank you for your help.   

    Apply the two fixes below in order as needed:
    Fix #1
    Launch iPhoto with the Command+Option keys held down and rebuild the library.
    Since only one option can be run at a time start
    with Option #4 and then #1 as needed.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.
    2 - click on the Add Library button, navigate to your Home/Pictures folder and select your iPhoto Library folder.
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the File ➙ Rebuild Library menu option.
    4 - In the next  window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments.  However, books, calendars, cards and slideshows will be lost. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

  • I can not upgrade to quicktime 7.7.3 for windows vista.  Error message says there is a problem with the program installer.  Any clue as to how to get around this.

    I can not download quicktime 7.7.3 for windows vista.  The error message says that there is a problem with the windows installer.  Any clues?

    The error message says that there is a problem with the windows installer.
    What's the precise text of the message, please? (There's a few different ones I can think of that you might be getting.)

  • I have a problem with the sync between iTunes and ipad2. I can not see the files in iPad. Help me please.

    I have a problem with the sync between iTunes and ipad2. I can not see the files in iPad. Help me please.

    Cannot see what files ? Music (synced music should appear in the iPod app), films/TV shows (Videos app), documents ... ?

  • Is anyone having a problem with the new iPad (Gen. 3) not staying connected to the charger? It seems to ALWAYS get jiggled loose and no longer be charging. My iPad 1 has no issue but I can't browse Internet w/o new iPad unplugging. Horrible!

    I notice that my new IPad (3rd generation) will not stay connected to the power cord at all, I'm not exagerating, if I plug it in and browse the Internet without fail it will become unplugged and I will have to push the plug back in (Ba-beep). Ive actually grown to despise that sound when you plug your iPhone or iPad in because it reminds me of how much money I spent on something that PHYSICALLY will not charge while I'm using it.
    I know the problem with it holding a charge while in use, I get it, the screen is amazing and it takes a lot to run the display, however, it is unacceptable to me that I can't even keep the thing plugged in while I'm using it. I can not even leave it on my Cal King bed overnight because I will wake up in the morning to find that the plug has been jiggled loose in a corner, so it's still attached but not making a connection thus not being charged. 
    I love the 4GLTE from Verizon and I love the iPad, but I'm actually using my 1st generation IPad while I am at home so I can leave my new $900 iPad on a table to charge free of incident so I can use the 4G while I'm away from wifi during the day. I have been getting more upset about this because I can not even use the Griffin extended cord to charge the iPad and be far from the plug because only the original apple sync/charge cord will have a better shot at staying in. Absolutely none of my non apple cables will stay in the iPad 3 while having it in my hands.
    The plug is at an angle, unlike the first iPad, not sure about the iPad 2. Please let me know if they have same issue.
    If anyone else is having this problem with the Gen 3 iPad please let me know because I'm tempted to do something about it with apple and I'm hoping that I just for some reason have a bad cable receiver or something and maybe I can get a replacement and enjoy the iPad as I had expected to. There is no reason why I should be even using my first iPad and I have friends that want to buy it but I am not selling it because I'm unable to sell it because I can't handle the new iPad while it's plugged in, that is ridiculous if it's a common issue so please let me know!

    Thanks for the swift reply, I have been looking online and a loose plug seems to be somewhat of an issue with many, I hope mine is actually a problem and not what others are experiencing. It's taken me this long to even reach out for the simple fact I HATE being a complainer but this is just horrible.
    Do you have an iPad 3 as well? And is yours not experiencing any issues close to mine?
    Thanks again!

  • Having Problems With The Neo2 ? Read This!!!!

    Hi,
    i just bought a neo2 motherboard, with a p4 2,6 HT and 512 mb Kingston hyper ram ( 2 peaces of 256, else it won't use the dual bandwith :D)
    In the beginning everything seemed fine, until i got some sudden reboots and other vague stuff. I read it could be the SB audigy messing things up. I removed the card and windows Xp pro runs fine now. no more sudden reboots or explorer not resonding crashes.
    But, i still had problems with games crashing. I got reboots. After i set the "automatic reboot after crash" to false, i got blue screens or lock-ups in my games.
    I wondered what it could be. Then i started to put my videocard ( a radeon 9700 pro 128 mb) in agp 4x mode instead of agp 8x! Now my games run without crashes, but benchmarks are not that high. 4780 marks with 3dmark 2003.
    I think i will send msi and Ati a mail concerning this problem. I don't know if it is PSU related. Maybe the videocard demands a little more power in agp 8x mode.
    Well, having probs with you're NEO2 ??
    remove the sb Audigy and turn the agp back to 4 using smartgart ( it's located in you're display settings screen ).
    First i tought it was a PSU related problem, because i swapped my 350 Watt enermax with a Q-tec 400 watt psu. The 400 watt PSU died while i was gaming. Maybe the enermax is the better PSU :D So, it could still be a PSU related problem. Maybe the agp 8x settings demands a lot more from you're psu. Anyway, i'll receive a 550 watt Antec PSU soon, so i can check this out....
    Btw. I cant run the motherboard in anything better than "slow" mode. In all other modes Xp won't boot. I haven't tryed it since the AGP is at 4X, but i don't think it will matter.
    Regards,
    Welcome to the real world NEO :D

    Ok.....
    i raised the memory voltage setting in the bios from 2.65 to 2.8 and the agp voltage from 1.5 to 1.7
    Everything seems fine, but games crash back to the desktop now without an error message or the either lockup.
    Whatever i do, i can't make the mobo crash in anything but games!
    Btw. the following message caught my attention, when i ran f1 2002 with directx 8.1. Since i have directx 9, i haven't seen it anymore. Maybe because the ati-drivers are made for directx 9....
    // Watchdog Event Log File
    LogType: Watchdog
    Created: 2003-10-04 02:02:53
    TimeZone: -60 - West-Europa (standaardtijd)
    WindowsVersion: XP
    EventType: 0xEA - Thread Stuck in Device Driver
    // The driver for the display device got stuck in an infinite loop. This
    // usually indicates a problem with the device itself or with the device
    // driver programming the hardware incorrectly. Please check with your
    // display device vendor for any driver updates.
    ShutdownCount: 9
    Shutdown: 0
    EaRecovery: 1
    EventCount: 2
    BreakCount: 2
    BugcheckTriggered: 1
    DebuggerNotPresent: 1
    DriverName: ati2dvag
    EventFlag: 1
    DeviceClass: Display
    DeviceDescription: RADEON 9700 PRO
    HardwareID: PCI\VEN_1002&DEV_4E44&SUBSYS_00021002&REV_00
    Manufacturer: ATI Technologies Inc.
    DriverFixedFileInfo: FEEF04BD 00010000 0006000E 000A18EA 0006000E 000A18EA 0000003F 00000008 00040004 00000003 00000004 00000000 00000000
    DriverCompanyName: ATI Technologies Inc.
    DriverFileDescription: ATI Radeon WindowsNT Display Driver
    DriverFileVersion: 6.14.10.6378
    DriverInternalName: ati2dvag.dll
    DriverLegalCopyright: Copyright (C) 1998-2002 ATI Technologies Inc.
    DriverOriginalFilename: ati2dvag.dll
    DriverProductName: ATI Radeon Family
    DriverProductVersion: 5.2.3790.2
    I wish i had another videocard to test. My radeon 9700 pro is getting suspicious...
    Regards,
    The real world

  • Is anyone having problems with the battery heating up and draining the power?  Mine has been doing this for about 2 months now.

    Is anyone having problems with the battery heating up and draining the power?  Mine has been doing this for about 2 months now.

    This is a major problem with Lollipop, but yo said it started 2 months ago.   Several people have fixed problem by removing FaceBook And Face book messenger and then re loading the apps again.   You might want to clear your cache before reloading.  Not sure this is your problem, but worth a try.  Good Luck

  • I have upgraded Apple Aperture from version 2 to version 3 and I'm having a problem with the "Highlights and Shadows" adjustment. According to the user's manual, I should have access to an advanced disclosure triangle which would allow me to adjust mid co

    I have upgraded Apple Aperture from version 2 to version 3 and I'm having a problem with the "Highlights and Shadows" adjustment. According to the user's manual, I should have access to an advanced disclosure triangle which would allow me to adjust mid contrast, colour, radius, high tonal width and low tonal width.
    If anyone has any suggestions as to how to access this advanced section, I'd be most grateful.

    Hi David-
    The advanced adjustments in the Highlights & Shadows tool were combined into the "Mid Contrast" slider in Aperture 3.3 and later. If you have any images in your library that were processed in a version of Aperture before 3.3, there will be an Upgrade button in the Highlights & Shadows tool in the upper right, and the controls you asked about under the Advanced section. Clicking the Upgrade button will re-render the photo using the new version of Highlights & Shadows, and the Advanced section will be replaced with the new Mid Contrast slider. With the new version from 3.3 you probably don't need the Advanced slider, but if you want to use the older version you can download it from this page:
    http://www.apertureexpert.com/tips/2012/6/12/reclaim-the-legacy-highlights-shado ws-adjustment-in-aperture.html

  • HT4864 I am getting a triangle with an exclamation point next to my inbox...it says: There may be a problem with the mail server or network. Verify the settings for account "MobileMe" or try again.  The server returned the error: Mail was unable to log in

    I can send but cannot recieve email
    This is the messege I am gewtting:
    There may be a problem with the mail server or network. Verify the settings for account “MobileMe” or try again.
    The server returned the error: Mail was unable to log in to the IMAP server “p02-imap.mail.me.com” using “Password” authentication. Verify that your account settings are correct.
    The server returned the error: Service temporarily unavailable

    Also if I go to system preferences accounts and re-enter the password it fixes the glitch sometimes.

  • Problems with the O2 blackberry data package on my Curve 3G.

    I have already informed O2 about this but they claim that I should be used the blackberry support services, but nothing there helps me!
    I got my Blackberry Curve 3G on September 9th this year and I put on the Blackberry Data Package bolt-on onto my phone on September 16th. I then received a text to say they've taken £5 from my credit and it will be up and running in the next 24 hours. Its now September 19th and my BBM is not working at all and I am extremely upset with the services and behaviour I have received from both O2 and Blackberry.
    Is there any way you can help? If this fails, I shall be forced to go back to the shop from where I got my Blackberry from and ask for their help.
    Many thanks, Jade.

    Can a bubble whistle Problems with the O2 blackberry data package on my Curve 3G.? The seat matures in your oar. The lad ices the pursuing method inside a resident. A judge spins against the vendor! The rose wows the hello. 
    filipina heart

  • Many problems with the 'Export to Text' (.txt) in CR Xi

    Hi,
    I have listed many problems with the 'Export to Text' (.txt) function of CR Xi.
    These problems are related to this export format only (meaning everything works fine in the Viewer or in the 'Export to PDF')...
    - Multi-columns layout do not export as Multi-column (export only a one column);
    - Numeric values with parenthesis for negative values or with a fix currency sign at the leftmost position are not exported correctly;
    - Fields having a Suppress formula which is "WhilePrintingRecords" do not appears when exported;
    - Fields with 'Suppress double value' checked are not always suppressed when exported to Text.
    - 'Keep Group Together' flag is not working.
    - 'Reset Page Number After' simply does not works when exported to text;
    - 'Keep object together' on TextBox/Section is not working.
    - Whenever a group is ending on the last line of a page, the the following page as the same Group header as the previous group with no records until the page is filled, then the PageBreak and PageHeader is missing but the records of the following group appears.
    I would like to know what is the status of the 'Export to Text' function (is it a deprecated function not supported anymore???).
    If still supported, when will these bugs be fixed???
    Thanks

    Hi Rene
    Export to Text is supported till date. Crystal Reports 2008 also supports this with Keep together working however when I tried with format with multiple columns, it didnot show up in the exported text file.
    Regards
    Sourashree

  • When going to update it says there is a billing problem with the previous purchase, I went in to fix it but it won't let me download it. How do I fix this problem?

    When going to update it says there is a billing problem with the previous purchase when I go to update it still won't let me download and all the info is correct. How do I fix this?

    You have to email iTunes Store Support about this issue now. You can get started here. Change the country in the upper right if necessary.
    https://ssl.apple.com/emea/support/itunes/contact.html

Maybe you are looking for