phoenix-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Samarth Jain <>
Subject Re: Phoenix JDBC in web-app, what is the right pattern?
Date Thu, 03 Sep 2015 19:26:03 GMT
Your pattern is correct.

Phoenix doesn't cache connections. You shouldn't pool them and you
shouldn't share them with multiple threads.

For batching upserts, you could do something like this:

You can do this via phoenix by doing something like this:

try (Connection conn = DriverManager.getConnection(url)) {
int batchSize = 0;
int commitSize = 1000; // number of rows you want to commit per batch.
Change this value according to your needs.
try (Statement stmt = conn.prepareStatement(upsert)) {
stmt.set ...
while (there are records to upsert) {
     if (batchSize % commitSize == 0) {
conn.commit(); // commit the last batch of records

You don't want commitSize to be too large since Phoenix client keeps the
uncommitted rows in memory till they are sent over to HBase.

On Thu, Sep 3, 2015 at 12:19 PM, Serega Sheypak <>

> Hi, I'm using  phoenix in java web-application. App does upsert or select
> by primary key.
> What is the right pattern to do it?
> - I create new connection for each request
> - prepare and execute statement
> - close stmt
> - close connection
> Does phoenix caches connections internally? What is the right way to batch
> upserts in current case?

View raw message