Make sure you run the commit on the same connection from which you do
the upsert. Looks like you're opening a new connection with each
statement. Instead, open it once in the beginning and include the
commit like Samarth mentioned:

Connection conn = getJdbcFacade().createConnection();
int result = conn.prepareStatement("upsert into unique_site_visitor
(visitorId, siteId, visitTs) values ('xxxyyyzzz', 1,
2)").executeUpdate();
            LOG.debug("executeUpdate result: {}", result);
//executeUpdate result: 1

            LOG.debug("selecting ...");
            ResultSet resultSet = conn.prepareStatement("select
visitorId from unique_site_visitor").executeQuery();
            while(resultSet.next()){
                LOG.debug("resultSet visitorId ::: {}",
resultSet.getString("visitorId"));
            }

On Tue, Jun 23, 2015 at 1:36 PM, Serega Sheypak
<[email protected]> wrote:
> Hi, thanks for the reply.
> I've tried to invoke commit explicitly, no luck. executeUpdate still returns
> 1 (I assume one record has been saved). Select returns empty resultset.
>
> 2015-06-23 18:11 GMT+02:00 Samarth Jain <[email protected]>:
>>
>> Hi Serega,
>>
>> Do you know if auto-commit is on for the connection returned by
>> getJdbcFacade().createConnection(). If not, you need to call
>> connection.commit() after executeUpdate()
>>
>> -Samarth
>>
>> On Tuesday, June 23, 2015, Serega Sheypak <[email protected]>
>> wrote:
>>>
>>> Hi, I'm testing dummy code:
>>>
>>> int result = getJdbcFacade().createConnection().prepareStatement("upsert
>>> into unique_site_visitor (visitorId, siteId, visitTs) values ('xxxyyyzzz',
>>> 1, 2)").executeUpdate();
>>>             LOG.debug("executeUpdate result: {}", result);
>>> //executeUpdate result: 1
>>>
>>>             LOG.debug("selecting ...");
>>>             ResultSet resultSet =
>>> getJdbcFacade().createConnection().prepareStatement("select visitorId from
>>> unique_site_visitor").executeQuery();
>>>             while(resultSet.next()){
>>>                 LOG.debug("resultSet visitorId ::: {}",
>>> resultSet.getString("visitorId"));
>>>             }
>>>
>>> returns no rows.
>>>
>>> What do I do wrong? Why I don't see results stored to HBase?
>>> I don't see any exceptions on client/server side.
>>>
>>>
>>> Are there any tricks with connection management?
>
>

Reply via email to