Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I implement batch insert ? #48

Open
arsis1 opened this issue Sep 18, 2019 · 3 comments
Open

How can I implement batch insert ? #48

arsis1 opened this issue Sep 18, 2019 · 3 comments
Assignees
Labels
documentation Improvements or additions to documentation

Comments

@arsis1
Copy link

arsis1 commented Sep 18, 2019

I am new to clickhouse and clickhouse4j.
And I can't see any helpful document about batch insert.

I think more example codes would be very helpful.
Thanks.

@doom369
Copy link
Collaborator

doom369 commented Sep 18, 2019

@arsis1 agree, this is something we have to work on. For now you can view the tests as usage reference. Typically this driver follows the regular JDBC syntax:

    try (Connection connection = dataSource.getConnection();
         PreparedStatement ps = connection.prepareStatement("insert into table (id) values (?)")) {
     for (var entry : entries) {
         ps.setInt(1, entry.id);
         ps.addBatch();
     }
     ps.executeBatch();
   }

@arsis1
Copy link
Author

arsis1 commented Sep 18, 2019

@doom369 Thanks, very helpful for me.

@arsis1 arsis1 closed this as completed Sep 18, 2019
@doom369 doom369 reopened this Sep 18, 2019
@doom369
Copy link
Collaborator

doom369 commented Sep 18, 2019

I'll reopen and will close when put some examples into the main page.

@doom369 doom369 self-assigned this Sep 18, 2019
@doom369 doom369 added the documentation Improvements or additions to documentation label Sep 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants