PreparedStatement and use of IN operator

Hi,
I created a PreparedStatement as follows:
PreparedStatement ps = conn.prepareStatement("SELECT COLUMNX FROM TABLEX WHERE COLUMNX IN (?)");
where COLUMNX is a simple integer column (primary key)
I then assign a value to the placeholder as follows:
ps.setInt(1);
And execute the query
ResultSet rs = ps.executeQuery();
This all works fine as long as I work with a single integer. What I'd like to do though is assign an array of ints to the placeholder. I've tried to this with setObject, but I always end up with "Invalid column type" SQLExceptions
Anybody any suggestions?
Thanks

I had faced the same issue and resolved it by dynamically preparing the prepared statement itself. For examle the sql: where <id_column> in (?,?,?)... adding number of placeholders (i.e '?') and ps.set statements in a loop.
I tried the sqlArray, but was unsuccessful.

Similar Messages

  • How to manipulate and use cell phone operating systems

    I have recently been messinga round with Netbeans 5.0 beta 2 with the MIDP pack. I am really enjoying it, but I am confused on something.
    I have an idea for a program that I want to create, but I want to be able to use it in an actual operating system. For instance, cingular, verizon, etc. all have phones that have operating systems on them. I don't know if they are operating systems as much as user interfaces. I want to know how I would be able to program an application for these systems specifically. Is there a way that you can access the code for these or anything like that? I really don't know how to ask this because I do not know much about the cell phone systems. Could somebody please inform me. Thank you.

    I hate that word only.
    There is no "ONLY" in the world of software. :P, well, I don't like the word "manipulate" either, so any disencourigement would be on it's place ;)
    There are ways to get to the lower level stuff but I
    believe that most Java developers would discourage
    it. The problem with it is that writing for that
    level means that the os is stable. Which is not the
    case. What would that have to do with anything? Palm OS, Symbian, an windows mobile (and even linux), are all stable. The other devices, simply don't have an OS, or at least, don't have an open OS where you can do stuff with. That's the real problem.
    Sure the os that the system uses may be
    excellent. But the next version of the hardware
    might not have the same underlying os. Try writing a
    program for a palm pro and running it on a new palm.
    Backwards compatible is not always there. Since the
    e rate of output from hardware developers is not
    slowing I'd avoid this. That's why you sould keep to api's. They ensure compatibility. Sure it might low stuff down sometimes, but who cares?
    Having said that. There is nothing like writing some
    low level code that pushes the edges of the hardware
    in directions even the os builders didn't think to
    go. Mind you java might not be the tool to do that.Very true, but this is out side of the scope of this forum, and therefor irrelevant.
    If you really want to do low level code, buy a nice cpu, make your own PCB and start programming without any api's, or even do it in assembler!

  • Cube Solve Time when using MAX Aggregation Operator

    Hello,
    We have created a cube to implement the count distinct measure we need.
    The cube contains only one measure (COUNT) and uses the MAX operator to aggregate across all other dimensions except for the one we want to count (which uses the SUM operator). We have set the precompute percent to 60% for the bottom partition and 0% for the top partition. The cube is compressed.
    The problem is that the SOLVE step for a partition when performing a COMPLETE cube build, seems to be taking a very long time and is taking up huge amounts of TEMPORARY tablespace.
    We have succesfully created another cube with the same dataset which uses the SUM operator across all dimensions.
    This cube build was completed in a reasonable amount of time even though we had 5 stored measures and 80% aggregation for the top partition.
    Is this behaviour expected when using MAX operator?
    Thank you,
    Vicky

    Thank you, David.
    As you said we are using mixed operators because we are doing a distinct count.
    We will try setting the precompute percent to 35%,although I'm a bit worried about the query performance in this case.
    Neelesh, I think that Atomic Refresh was set to TRUE during the last refresh but the cube was the only object in the build script.
    No other cubes or dimensions were maintained in the same build so I don't think it could have affected the use of TEMP tablespace.
    Generally we don't use Atomic Refresh.
    Thank you,
    Vicky

  • Using PreparedStatement and the Oracle Error ORA-1000

    Hi,
    I have a question about PreparedStatement objects that is not so simple to explain for me. What I would like to know is: if I use a PreparedStatement following traditional and generic steps:
    1- PreparedStatement pStmt = Connection.prepareStatement(sQuery);
    2- pStmt.setXXX(i,j);
    n - pStmt.setXXX(i,j);
    n+1 - ResultSet rs = pStmt.executeQuery();
    n+2 - while(rs.next()){ ... retrive ResultSet data  ... }
    n+3 - rs.close()
    n+4 - back to point number 2
    and at the end (as you can see in the point numbered n+4), instead of closing the PreparedStatement pStmt using the close() method, I reuse the PreparedStatement pStmt comeing back to the point numebr 2 and setting again all its parameters with new values ... then ... what heppens in the Oracle database ? Has been the cursor (so the mamory area), associated to my PreparedStatement object pStmt, duplicated or is it the same ?
    I know that Java allows you to do this kind of operations with PreparedStatement, and I know that in tha Java Documentation is explained to follow this strategy to optimize the execution time because in this way the same PreparedStatement is precompiled and prepared only once. But if I do a for loop following the steps explained before, after many iterations I have the error "ORA-1000: maximum open cursors exceeded". This error is the reason of my question. Does this error means that it's mandatory to close a PreparedStatement always, otherwise if you reuse it without closing it then the corresponding database cursor will be duplicated ? If it is so, then I think this is a contradiction with official java documentation ...
    I'm using Oracle8i (version 8.1.7) and Oracle JDBC Thin Driver (Windows NT) for use with JDK 1.2.x. Moreover, in my database istance the parameter "maximum open cursor" is equal to 800 ...
    Thank you very much for suggestions :-)

    There is no need to close a prepared statement or its resultset for every iteration.
    After the first iteration in a loop, all subsequent executions of it will close the previous resultset. By adding close() method, you are making one extra costly call to the DB for no reason.
    Following is the sample code.I know what you are saying. In fact at the beginning I wrote my code in the same way of your sample (see the code of my first post at the begin of this page).
    But doing so, after thousand iterations of the loop, I had "Oracle Error ORA-1000 : maximun open cursor exeeded" even if in my database istance the parameter "maximum open cursor" is equal to 8000.
    At this moment in my code, for each iteration, I close the PreparedStatement and in this way I don't have anymore the error :-((
    So it seems that only in theory we can reuse a preparedStatement without closing it. In fact if we see the oracle system table "$open_cursor" (as Konrad Pietzka suggest me) we can find that, for each interation,
    at our line code "rs = pstmt.executeQuery();" correspond a new cursor in the database: this means that for each method "pstmt.executeQuery()" the database open a new cursor and do not use the previous one as it should.
    I posted a question two months ago to search if someone had the same problem (it seems that Konrad Pietzka had the same situation) and was able to explain me what is the cause.
    The only reason I found by myself for this problem, is that probably the Oracle JDBC Thin Driver for Windows NT/2000 has some bugs... but I'm not sure ...
    Thank you very much for you time !!
    bye :-))
    Fidalma

  • How do I erase my hard drive? My initial operating system was Snow Leopard but I have upgraded to Mavericks OS. My Snow Leopard install disk ejects when I try and use it.

    How do I erase my hard drive? My initial operating system was Snow Leopard but I have upgraded to Mavericks OS. My Snow Leopard install disk ejects when I try and use it.

    Do a backup,  preferable 2 separate ones on 2 drives. Boot to the Recovery Volume (command - R on a restart or hold down the option/alt key during a restart and select Recovery Volume). Run Disk Utility Verify/Repair and Repair Permissions until you get no errors.  Reformat the drive using Disk Utility/Erase Mac OS Extended (Journaled), then click the Option button and select GUID. Then re-install the OS.
    OS X Recovery
    OS X Recovery (2)
    When you reboot, use Setup Assistant to restore your data.

  • Hello guys..does anybody know how to install and use adobe master collection with the new lion?   I need to use Flash and illustratore, but apparently those programmes are incompatible with the new operative sistem...   I am a new mac users and I'd like t

    Hello guys..does anybody know how to install and use adobe master collection with the new lion?
    I need to use Flash and illustratore, but apparently those programmes are incompatible with the new operative sistem...
    I am a new mac users and I'd like to know if there are other similar programmes I can use with lion!

    Lab79 wrote:
    Are you on Apple's payroll?
    well dude I can only let you know that as I work with those programme I don't have to pay for it is my company that pays the programme I whant to use( that's why I was asking if there where other programmes ..that I could use with lion insted that Illustrator and Flash!)..I know Adobe since 2005 and I can say that Adobs products are very good...I think that if it's an Adobe probleme or fault ..they will solve it very soon...but unfortunally I have the impression that after Jobs passed away Appel decided to change politics..and everything started to go very bad! (see FCP X)..
    good luck with apple dude..
    Where is the Apple problem? I have CS4 and CS5 running perfectly fine on my Macbook Pro. Installed 5 after Lion upgrade. Worth every cent. Adobe did have some catching up to do with Lion but with the CS5.5 update all runs fine. But not yours. So it is a problem with the Lion OS? You say you have been with Adobe since 2005. So you would be aware of all the other issues that Adobe had catching up with past Oss in Mac and Windows then. They get it right, but it is up to them. It is not up to Apple, nor Microsoft for that matter, to run around and check that every software developer in the world is running their business properly.
    And what has politics got to do with anything. Some people just have to blame Software for their poor Hardware maintainence of failure of the same.
    <The only think I can really do is to go back on my old windows...give back this orrible lap top and ask for my money back!>
    Great suggestion. You should go with that one, but good luck getting a refund.
    Bye

  • Error message has just occurred... This copy of itunes is corrupted. Please reinstall itunes. I'm using a Macbook operating on version 10.6.8 - not that this means anything to me. I just want to preserve my library and playlists! What do I do?!

    Error message has just occurred... This copy of itunes is corrupted. Please reinstall itunes. I'm using a Macbook operating on version 10.6.8 - not that this means anything to me. I just want to preserve my library and playlists! What do I do?!

    Let's try a repair install of iTunes.
    Restart the PC first.
    If you're using Vista or 7, now head into your Uninstall a program control panel, select "iTunes" and then click "Repair".
    If you're using XP, head into your Add or Remove Programs control panel, select "iTunes", and click "Change". Select "Repair" and click "Next" as per the following screenshot:
    Can you launch your iTunes now?

  • When legally ipad2 with 3G would be available in Thailand?  Can I buy it from US and use it with 3G operator in Thailand?

    When legally ipad2 with 3G would be available in Thailand?  Can I buy it from US and use it with 3G operator in Thailand?

    The iPad 2 is available in Thailand now, though I don't know whether you can find one it stock. The iPad 2 continues to be in short supply everywhere in the world. A US iPad with GSM 3G should be able to work with any carrier worldwide that offers GSM service and a suitable data plan. You'll need to be sure you purchase the AT&T version of the iPad if you purchase in the US, NOT the Verizon version which uses a different cell technology.
    This has been asked and answered in these forums multiple times already, by the way. A quick search or browse of the forums and you would not have had to wait for a response.
    Regards.

  • Hi I am in travel and I use from Iran operator. but my iphone is locked for it. please open it for me

    hi I am in travel and I use from Iran operator. but my iphone is locked for it. please open it for me or help me anyway can please

    Since the iPhone is not officially sold in Iran, & there are no supported carriers there, you couldn't have an iPhone locked to a carrier in Iran.
    At any rate, if you do have a carrier locked iPhone, you need to contact the carrier the phone is locked to to get it officially unlocked. No one here can help you, nor can/will Apple.

  • Using two seperate operating systems on a Mac, and a smart-phone to better integrated the flows!

    I am considering to get a new Mac.
    In that I want to be able to use two seperate operating systems. The Mac operating system and maybe either a windows or linux or an other useful and functional alternative!
    The reason for this is, that I have several laptops incl. an iPad. I have concluded that iPad isnt that useful for my needs till now, its not very functional for my needs. I am also going to upgrade my smart mobile still considering functional alternatives (would like to hear yoru thoughts about this as well)!
    I want to integrate them into one machine only and utilize cloud  and / or an external Disk, and be better able to use useful apps and software that are not available on either one of the systems on their own my own system!
    Usage will be both for biz and private, but at the end usefulness, and functionality will play a big part in my final decision!
    Do you think this is practical, useful and cost effective way doing it the way I want to do?

    My reason for wanting to have windows on my Mac is to be able to utilize, some applications that are not available for Mac OS!
    In the past I raised few points relating to that, and wasnt able locate details to consider to have only a Mac system. Thats why I had to have few laptops to handle all! I got myself an iPad(1) but again it didnt met the exact needs that I have!
    Thats why I am going to integrate all in one new system(Mac), and exchange and process while on the road via smartphone or something that is between a smartphone and tablet!
    As to smartphones; I hear positive notes on iPhone, but seems to have some issues with its antena, the new Moterola seems great to exchange files anywhere, and the new Samsung Galaxy, very advanced. However what I lack at this stage is user experiences to see if any of them can meet my needs, and what the best combination could be for efficiency, speed and value for money(laptop, operating sytem, smartphone).
    I am tired of crashes, frozen screens, or not able to open files or pics because they are not compatible in some ways! I try to maintain, clean and update my systems, but some stuff does comes in between despite all!
    Anyhow, thank you for your support, I will try to do some reading on the keywords you used, I might get back to you for some more leads!
    Thank you once again!:)

  • I have an original iPad and downloaded the new operating system.  Now' I cannot write on my Contacts or Calendar apps, and my Pages app (purchased) has lost the ability to use the bold, underline, and italics functions.  Does anyone know how to fix these

    I have an original iPad and downloaded the new operating system.  Now, I cannot add to my contacts or calendar apps, and Pages ( which I purchased) is not allowing me to use the bold, underline, and italics functions.  Does anyone know how to solve this problem?

    No, it stays with the current OS (iOS5 in this case) - Apple doesn't allow downgrading iOS
    If you are syncing to a desktop, you shoudln't lose anything. If you aren't syncing, then that's the first thing you should do, to protect contacts etc.
    the other thing is, when the iPad is connected to iTunes, right-click its name in the Devices list and choose Back Up.
    That way, when yoiu do the restore, everything should come back as was.

  • Database Procedure Calling by Using PreparedStatement and CallableStatement

    Hi
    We can execute Database Stored Procedure by using PreparedStatement and CallableStatement as well.Then what is the significance of having CallableStatement.
    Please let me know the difference between these two Statement objects particularly in Stored Procedures Execution.
    Thanks in advance
    Basha007

    A callable statement excecutes a stored procedure that's stored and run on the database server.
    A prepared statement doesn't require a database stored procedure. It's parsed and cached by the JDBC driver, and allows you to specify parameters and bind values to them at runtime. Those are usually used in loop constructs where you want to repeatedly execute the same SQL with different values.
    Not all RDBMS support stored procedures (e.g., MySQL), but every driver I've used allows PreparedStatements. - MOD

  • Using the "this" operator to pass variable references among classes and met

    Hi guys still trying to understand how to use the "this" operator
    can some one tell what I am doing wrong or just make this work for me to see how it works.
    public class ReferencePassing
    public static void main(String[]args)
    ReferencePassing rp = new ReferencePassing();
    System.out.println(rp);
    public ReferencePassing()
    HelperObject ho = new HelperObject(this);
    System.out.println(this);
    class HelperObject
    private ReferencePassing MyReferencePassingBuddy;
    public HelperObject (ReferencePassing theRp);
    MyReferencePassingBuddy = theRp;
    print();
    public void print()
    System.out.println(MyReferencePassingBuddy);
    }

    Hi guys still trying to understand how to use the "this" operatorYou're still trying to understand how to write methods and constructors.
    public HelperObject (ReferencePassing theRp);Syntax error at ';'.
    MyReferencePassingBuddy = theRp;
    print();
    public void print()Syntax error: '}' expected.

  • Problem with iphone 4,my phone still using ios 5 operating system and now it wont work ad tried to update it

    Help!!! My iphone is still using ios 5 operating system due to laptop issues and unvarnished able to update it,my husband has tried to update it and now its saying phone in recovery!  If I restore to original settings will i loose everything like music and photos??!!!!!

    Hi there Laura,
    Welcome to Apple Support Communities.
    It sounds like your iPhone is in recovery mode and you’re concerned about restoring it to factory settings because you don’t want to lose any data. The first article linked below provides a lot of great information about restoring an iOS devices to factory settings, including how to restore from any backups that you may have created with iTunes.
    Use iTunes to restore your iOS device to factory settings - Apple Support
    Also, if you want more information about recovery mode, take a look at the article linked below.
    If you can't update or restore your iPhone, iPad, or iPod touch - Apple Support
    Cheers,
    -Jason

  • Using mountain lion operating system, downoaded iphoto 9.4 update, aperature 3.4.3 update and still cannot access photo stream.  now what??

    Using mountain lion operating system, downoaded iphoto 9.4 update, aperature 3.4.3 update and still cannot access photo stream.  now what??

    With Aperture, you should be able to use Photo Stream now, but you need iPhoto 9.4.2 > http://support.apple.com/kb/DL1608
    After updating iPhoto to the latest version, open System Preferences > iCloud and tick Photo Stream. Finally, you will have to turn on Photo Stream on iPhoto and Aperture choosing Photo Stream on the sidebar of both programmes

Maybe you are looking for

  • HP Photosmart Premium C310 Series.......Printhead Problem

    I have the HP Photosmart Premium C310 Series Printer. It will no longer print. There is an error message of "Printhead Problem", with the instructions of:  Remove all Cartridges. Next, left black latch and remove printhead. Then re-install Printhead

  • Problems with keywords assignment (hierarchy is included)

    Hi group, this probably happens after I was letting Lightroom to a catalog optimization, but I am not quiet sure about this. So what happens: As you know, you can create a keyword tag hierarchy and sometimes LR does this automatically. If I now do so

  • Unable to print pages directly from internet explorer 9 script error 2126

    HP photosmart wireless b109n-z computer Packard Bell One Two L5861 64bit I am unable after going to many forums where it seems to be quite a problem and trying different ways to try and rectify a error mesage An error has occurred in the script on th

  • How to install app in sd card in lenovo A328?

    Dear, lenovo community.                     please tell me how to move app in sd card , please give us answer in a video or in a detailed form . So , that i should solve the problem?

  • Query of queries case sensitive

    Hi, I've a question regarding this issue.  I am pulling data from an xml file and dump that data into query of queries then output them.  The problem is when I try to order the query ASC, the upper will be top and the lower will be on the bottom.  Is