Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5933927
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T15:02:32+00:00 2026-05-22T15:02:32+00:00

Kindly give me some example that how we can use INSERT INTO ALL STATEMENT

  • 0

Kindly give me some example that how we can use “INSERT INTO ALL STATEMENT” in jdbc prepared statement inside a jsf bean?

Actually i want to take employee id’s of present employees using single jsf page and using one textbox for each employee id.

How can i use INSERT INTO ALL statement to achieve this?

Following is my code snippet.

AttendanceBean.java:

public class AttendanceBean {
private int atteid;                    
    private String attdname; 
private int attday;
private int attmonth;
private int attyear;

    public static Connection getAttConnection() throws Exception {
    String driver = "oracle.jdbc.driver.OracleDriver";
    String url = "jdbc:oracle:thin:@localhost:1521:globldb3";
    String username = "scott";
    String password = "tiger";
    Class.forName(driver);
    Connection conn = DriverManager.getConnection(url, username, password);
    return conn;
  }
public String addAttendance(){
    Connection conn = null;
    PreparedStatement pstmt = null;
    boolean committed = false;
try {
    conn = getAttConnection();
    conn.setAutoCommit(false);
    String query = "INSERT ALL INTO attendance VALUES (?,?,?,?,?)";
    pstmt = conn.prepareStatement(query); 
    pstmt.setInt(1,this.atteid); 
    pstmt.setString(2,this.attdname);
    pstmt.setInt(3,this.attday);
    pstmt.setInt(4,this.attmonth);
    pstmt.setInt(5,this.attyear);
            pstmt.executeUpdate();
        conn.commit();
        conn.setAutoCommit(true);
        committed = true;
    return "home.xhtml";
    } catch (Exception e) {
        e.printStackTrace();
        return "CRM.xhtml";
    }   finally {
            try{
                if (!committed) conn.rollback();
                if (pstmt != null) pstmt.close();
                if (conn != null) conn.close();
            }catch(Exception e){
                e.printStackTrace();
            }
        }
      }
    }    
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T15:02:33+00:00Added an answer on May 22, 2026 at 3:02 pm

    The correct SQL syntax for a multi-insert is:

    INSERT INTO 
        tbl (col1, col2, col3) 
    VALUES
        (val1a, val2a, val3a),
        (val1b, val2b, val3b),
        (val1c, val2c, val3c),
        ...
    

    However, in JDBC, you’d better use PreparedStatement#addBatch() in a loop, followed by a executeBatch() to do a multi-insert. Here’s a kickoff example:

    private static final String SQL_INSERT = "INSERT INTO tbl (col1, col2, col3) VALUES (?, ?, ?)";
    
    public void save(List<Entity> entities) throws SQLException {
        Connection connection = null;
        PreparedStatement statement = null;
    
        try {
            connection = database.getConnection();
            statement = connection.prepareStatement(SQL_INSERT);
    
            for (Entity entity : entities) {
                statement.setObject(1, entity.getCol1());
                statement.setObject(2, entity.getCol2());
                statement.setObject(3, entity.getCol3());
                statement.addBatch();
            }
    
            statement.executeBatch();
        } finally {
            if (statement != null) try { statement.close(); } catch (SQLException ignore) {}
            if (connection != null) try { connection.close(); } catch (SQLException ignore) {}
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Kindly give me some hint of matrix multiplication using MTL 2. Or any ref.
I want to sniff network packets without wincap library, kindly give me some hints
I am specifically looking for an example which use a) WCF & REST. After
Is there any way to connect mysql database with dojo web pages. Kindly give
I have a XML file template like this that comes from some IC chips,
Can we add multiple rows in the database table from one JSF page in
Would someone kindly assist me with the following? I have two DataGridView objects that
Kindly point towards theory/material to read for understanding colors and what makes a good
I need to get substed drive letter in Perl. Could anyone kindly help me?
Ok, so I'm a little confused as to why I can't find this anywhere,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.