More than 1 preparedStatement  object using batch update

Hey how can I execute more than 1 preparedStatement object using batch update..Pls explain with a code(java)
Thanks

// turn off autocommit
con.setAutoCommit(false);
PreparedStatement stmt = con.prepareStatement(
     "INSERT INTO employees VALUES (?, ?)");
stmt.setInt(1, 2000);
stmt.setString(2, "Kelly Kaufmann");
stmt.addBatch();
stmt.setInt(1, 3000);
stmt.setString(2, "Bill Barnes");
stmt.addBatch();
// submit the batch for execution
int[] updateCounts = stmt.executeBatch();
search in google for more information

Similar Messages

  • How do u save datas more than one table using net beans ide using JSF

    Hi,
    I am new to JSF.
    I save / delete / update / New master table using POJO (Plain Old Java Objects), database - oracle and Toplink Persistence Unit.
    How do u save data more than one table using net beans ide using JSF (I am using POJO) ?
    and also Tell me the reference book for JSF.
    Thanks in advance.
    regards,
    N.P.Siva

    SivaNellai wrote:
    I am new to JSF.
    So, I am using net beans IDE 6.1 from sun microsystem. It is a free software.No, you don't drag'n'drop if you're new to JSF. Switch to source code mode. Write code manually, with the help of IDE for the speed up.
    So, please guide me the reference books, articles. I need the basic understanding of JSF, net beans IDE.[JSF: The Complete Reference|http://www.amazon.com/JavaServer-Faces-Complete-Reference/dp/0072262400] is a good book. The [JSF specification document|http://jcp.org/aboutJava/communityprocess/final/jsr252/index.html] is also a good reading to understand what JSF is and how it works. There are also javadocs and tlddocs of Sun JSF Mojarra.

  • How to backup more than one database using powershell

    I am Trying to backup more than one database using the following script but no luck. I want user to type on command line the database they want to backup, e.g all databases that have "test" at the front like test.inventory, test.sales so i want
    user to type test.* and it backs up all databases related to test. Here is the script
        #$date = Get-Date -Format yyyyMMddHHmmss
        #$dbname = 'test.inventory'
        $dbToBackup = "test.inventory"
        cls
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoExtended") | 
        Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.ConnectionInfo") 
        | Out-Null
        [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SmoEnum") | Out-
        Null
        Add-Type -AssemblyName "Microsoft.SqlServer.Smo, Version=10.0.0.0, Culture=neutral,   
        PublicKeyToken=89845dcd8080cc91"
        $server = New-Object Microsoft.SqlServer.Management.Smo.Server($env:ComputerName) 
        $server.Properties["BackupDirectory"].Value = "C:\_DBbackups"
        $server.Alter()
        $backupDirectory = $server.Settings.BackupDirectory
        #display default backup directory
        "Default Backup Directory: " + $backupDirectory
        $db = $server.Databases[$dbToBackup]
        $dbName = $db.Name
        $timestamp = Get-Date -format yyyyMMddHHmmss
        $smoBackup = New-Object ("Microsoft.SqlServer.Management.Smo.Backup")
        #BackupActionType specifies the type of backup.
        #Options are Database, Files, Log
        #This belongs in Microsoft.SqlServer.SmoExtended assembly
        $smoBackup.Action = "Database"
        $smoBackup.BackupSetDescription = "Full Backup of " + $dbName
        $smoBackup.BackupSetName = $dbName + " Backup"
        $smoBackup.Database = $dbName
        $smoBackup.MediaDescription = "Disk"
        $smoBackup.Devices.AddDevice($backupDirectory + "\" + $dbName + "_" + $timestamp +   
        ".bak", "File")
        $smoBackup.SqlBackup($server)
        #let's confirm, let's list list all backup files
        $directory = Get-ChildItem $backupDirectory
        $backupFilesList = $directory | where {$_.extension -eq ".bak"}
        $backupFilesList | Format-Table Name, LastWriteTime

    Or i am using this script which backs up everything except tempdb but dont know how to modify this so that it backs up up all test related databases
    Is there a way that i use test.*
    [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.SMO") | out-null
    $s = new-object ("Microsoft.SqlServer.Management.Smo.Server") $instance
    $bkdir = "C:\_DBbackups" #We define the folder path as a variable 
    $dbs = $s.Databases
    foreach ($db in $dbs) 
         if($db.Name -ne "tempdb") #We don't want to backup the tempdb database 
         $dbname = $db.Name
         $dt = get-date -format yyyyMMddHHmm #We use this to create a file name based on the timestamp
         $dbBackup = new-object ("Microsoft.SqlServer.Management.Smo.Backup")
         $dbBackup.Action = "Database"
         $dbBackup.Database = $dbname
         $dbBackup.Devices.AddDevice($bkdir + "\" + $dbname + "_db_" + $dt + ".bak", "File")
         $dbBackup.SqlBackup($s)

  • Methods that return more than one object.

    Hello everyone,
    I don't know if this has ever been proposed or if there's an actual solution to this in any programming language. I just think it would be very interesting and would like to see it someday.
    This is the thing: why isn't it possible for a method to return more than one object. They can receive as many parameters as wanted (I don't know if there's a limit), but they can return only 1 object. So, if you need to return more than one, you have to use an auxiliary class...
    public class Person {
       private String name;
       private String lastName;
       public Person(String name, String lastName) {
          this.name = name;
          this.lastName= lastName;
       public String getName() {
           return name;
       public String getLastName() {
           return lastName;
    }So if you want to get the name of somebody you have to do this, assuming "person" is an instance of the object Person:
    String name = person.getName();And you need a whole new method (getLastName) for getting the person's last name:
    String lastName = person.getLastName();Anyway, what if we were able to have just one method that would return both. My idea is as follows:
    public class Person {
       private String name;
       private String lastName;
       public Person(String name, String lastName) {
          this.name = name;
          this.lastName= lastName;
       public String name, String lastName getName() {
           return this.name as name;
           return this.lastName as lastName;
    }And you would be able to do something like:
    String name = person.getName().name;and for the last name you would use the same method:
    String lastName = person.getName().lastName;It may not seem like a big deal in this example, but as things get more complicated simplicity becomes very useful.
    Imagine for example that you were trying to get information from a database with a very complex query. If you only need to return 1 column you have no problem, since your object can be an array of Strings (or whatever type is necessary). But if you need to retrieve all columns, you have three options:
    - Create 1 method per column --> Not so good idea since you're duplicating code (the query).
    - Create and auxiliary object to store the information --> Maybe you won't ever use that class again. So, too much code.
    - Concatenate the results and then parse them where you get them. --> Too much work.
    What do you think of my idea? Very simple, very straight-forward.
    I think it should be native to the language and Java seems like a great option to implement it in the future.
    Please leave your comments.
    Juan Carlos García Naranjo

    It's pretty simple. In OO, a method should do one thing. If that thing is to produce an object that contains multiple values as part of its state, and that object makes sense as an entity in its own right in the problem domain--as opposed to just being a way to wrap up multiple values that the programmer finds it convenient to return together--then great, define the class as such and return an instance. But if you're returning multiple values that have nothing to do with each other outside of the fact that it's convenient to return them together, then your method is probably doing too much and should be refactored.
    As for the "if it increases productivity, why not add it?" argument, there are lots of things that would "increase productivity" or have some benefit or other, but it's not worth having them in the language because the value they add is so small as to no be worth the increase in complexity, risk, etc. MI of implementation is one great example of something that a lot of people want because it's convenient, but that has real, valid utility only in very rare cases. This feature is another one--at least in the domain that Java is targetting, AFAICT.

  • Highliting more than one word using JTextArea

    I want to highlight more than one word using JTextArea. For example.
    My car color is red.
    My friend's car color is black.
    I want to highlight "red" in first sentence and friend in second sentence using JTextArea (both the sentences are in JTextArea). Can any one help me how to write program for this please.
    Thanks in advance
    regards
    V.Umashanker

    Highlighter h = textArea.getHighlighter();
    Highlighter.HighlightPainter p =
        new DefaultHighlighter.DefaultHighlightPainter(color);
    Object h1 = h.addHighlight(start1, end1, p);
    Object h2 = h.addHighlight(start2, end2, p);...and to remove them:h.removeHighlight(h1);
    h.removeHighlight(h2);This is assuming that you want both words highlighted in the same color (but a different color than the selection). If you want different colors, you'll have to create a separate painter for each color.

  • If possible, one SoftReference refer to more than one object?

    Hello,
    I want design a cache to keep huge number objects.
    If create a new SoftReference intance for each object,
    will take a lot of space and time.
    So, one SoftReference refer to more than one object, if possible?

    or arrange your objects into buckets somehow and have
    soft references to the bucketsEn, It's a good idea. but I think it doesn't work.
    My problem is:
    There are many caches(cache1, cache2.......), they may cache a lot of same object instance.
    then, I want to keep a object pool, and try to get the equal object from pool before put a object into a cache, if there is an equal object, put the equal object into cache, if there is no equal object, put the target object into pool and cache. the object pool may very huge because there is lot of objects. So it's necessary to release the object in the pool if no cache referes to the object(the caches contain the object may removed). Then SoftReference come into my mind. I try to create a SoftReference for each object in the pool, but soonly, I find there are two problems:
    1, A lot SoftReference instances take much memory.
    2, Need some time to new and reclaim the SoftReference intances.
    I think SoftReference may work fine to cache the object frequently used,
    but the object number can't be too large.
    Now, I don't use object pool. replace starting a thread to scan those cache s and combine the same objects intervally. It can scan about 2000,000 objects one second in my pc. It's ok for my project. But I am looking for some better way still.

  • Selecting more than one object at a time

    Hi guys and girls
    I am trying to select more than one object on my artboard and Shift+clicking on the next one isn't working...
    I am creating an interactive form in Indesign and realised that I have everything on one layer... I have radio buttons for yes/no questions and I wanted to move them to a new layer for ease of selection and editing...
    I have tried selecting one and then Shift+Click on the next but it just moves which one is selected...?
    I even tried creating a new layer and dragging them up to the new layer...no Dice?
    Has anyone any ideas....Please!
    bookie56
    P.S. Just realised that the radio buttons are part of the text? Could this be the reason why I can't move them. Doesn't solve the question about selection though

    Hi AnshulJain19
    OK! sort of guessed that....thanks for coming by.
    I am still on this form and have created multiline text boxes for two of my text boxes.... have checked the positioning of the boxes - but when I write in the box in Adobe Acrobat the text is quite a long way above the line...this is only happening with the multiline boxes.
    Is there a way to export a font colour for the boxes or does this need to be done in Acrobat Reader...?
    I have a standard dark background for my page and that needs a White font...when I fill the form in it is black...
    bookie56

  • More than one user "using an expression" in a BPM Task

    Hello,
    I want to send a notification step for multiple users. I see two options
    1. Choose one or more UME principals.
    2. Use an expression.
    However I have to send the notification for more than one user using an expression. I'm using this expression, 
    getPrincipal(DO_xyz)
    but this only works for one user. I need something like this
    getPrincipal(DO_xyz);  getPrincipal(DO_xyz2);  getPrincipal(DO_xyz3)
    But this is not possible. I can't use a group because all this information is dynamic and it's born within the process.
    Please, How can I solve this?
    Best Regards
    SU

    Hello Abhijeet,
    I've seen that I can use the getPrincipals adding in the XSD an string with 1..* cardinality. However I don't know how to map an attribute from the UITask to that new attribute in the XSD because in Web Dynpro I can't create an string with cardinality 1..*
    I've tried to create a node (1..*) with a String inside in the UI but I couldn't map it to the process context, it shows me an error that I cannot map a node to a String.
    Thanks
    Regards
    SU

  • Is it possible to install Lightroom 4.1 on more than one computer using the same product code?

    is it possible to install Lightroom 4.1 on more than one computer using the same product code?

    Yes, your license key is cross platform PC & or Mac you are allowed to have two current installations with one in use at any point in time. You can uninstall / install as many times as is necessary so long as you adhere to the limits.

  • How to pull groups from more than one OU using weblogic "All Groups Filter" from AD.

    Hi,
    Please help me for pulling groups from more than one OU using weblogic "All Groups Filter" from AD.
    AD structure is:
    c001639domain.local
           ||
           ||
        OU=Security_Groups
                      ||
                      ||
                      >> OU=CORP_ECM---> n number of group
                      >> OU=CORP_hodata--> n number of group
                      >> OU=CORP_citrix--> n number of group
                      >> OU=CORP_driver --> n number of group
                      >> OU=CORP_temp --> n number of group
    Requirement is i want to filter groups from OU=CORP_ECM and OU=CORP_hodata.
    Thanks,
    Jagan.

    I used below option but its not working getting zero groups.
    (&(objectClass=group)(|(ou=CORP_ECM,dc=Domain,dc=com)(ou=CORP_hodata,dc=c001639domain,dc=local)))

  • Insert more than 4000 characters using sql plus

    I have a SQL script that creates a database. The problem is that some of the fields are longer than 4000 characters in the INSERT statement and Oracle doesn't seem to like it.
    The field is a clob and works fine in the application (i.e. I can insert more than 4000 characters using the app) - how do I achieve this in a SQL script?
    Any help is much appreciated.
    Cheers,
    Steve

    Hi,
    This pl/sql block works absolutely fine in SQL*Plus inserting > 4000 characters into clob column:
    declare
    l_str varchar2(8000);
    l_str1 varchar2(2400) := 'first part of the verly long string...';
    l_str2 varchar2(2400) := 'second part of the verly long string...';
    begin
    l_str := l_str1 || l_str2;
    insert into tmpl values (l_str);
    end;
    So, you'll have to replace inserts with pl/sql blocks in your script.
    Tested in Oracle 8.1.7.0.0
    Regards,
    Andrew Velitchko
    BrainBench MVP for Developer/2000
    http://www.brainbench.com

  • Can i backup more than one iphone using itunes on pc

    can i backup more than one iphone using itunes on pc

    Yes. It ought not to matter, but make sure you give each device a unique name.
    tt2

  • My Calendar won't synch back more than 1 year using IOS8 and Outlook365

    My Calendar will not synch back more than 1 year using IOS8 and Outlook365 even though it is set to synch all events, THis is new with IOS8

    Think about it....meetings you had with the same person/business....trips you took......days in a country for tax/regulatory reasons....dates of important past meetings or events...date someone died....date someone was born.....last time you had a medical exam ... date you started a medicine......date you made a deposit.....I use Calendar as my diary...it's easy and doesn't involve writing a lot and has an excellent search

  • [Q] Can Vision track more than one object in a same area - objects that might cross?

    Hi,
    Sorry for that long title, but that's my question.
    Can Vision track more than one object in a same area - objects that might cross?
    Because I'm able to do it, extracting XY, but it looks like "IMAQ Count Objects" doesn't track object frame after but frame, but extract the XY coordinates always in the same way, like example starting from top and everytime he sees an object, he extracts the XY, but if the objects cross (then he will extract XY without caring which objects was the previous one but just based on "scan from top to bottom").
    This is why I opened this topic in the non Vision forum part : http://forums.ni.com/t5/LabVIEW/Sort-XY-by-closest/td-p/2440428
    Thank you,
    Sébastien
    Solved!
    Go to Solution.

    Hi,
    In fact, IMAQ count object order the object regarding their top most and left most pixel, but not regarding their gravity center point.
    Axis origin of an image is situated on the left top corner.
    You need to refer to other caracteristics such as shape or color to identify your objects.
    Regards

  • How to update more than one table using EO

    Hi frnds,
    Can someone provide me a doc/link which explain in detail how we can we update more than one PL/SQL tables using entity objects(on which VOs are based).
    Till date I have been doing this using PL/SQL procedures but now my requirement is to achieve it thru EO.Someone suggested me use VL to achieve plz help
    Thanks & Regards,

    Hi,
    That would be very nice of you,plz send me the docs and also send me similar docs that would be beneficial for a beginner like me.
    My id is [email protected]
    Thnx for your time.

Maybe you are looking for