How to use Auto-Commit and transactions in Phoenix ??

33 views
Skip to first unread message

Vishal Biradar

unread,
Jul 6, 2017, 4:08:26 AM7/6/17
to Tephra User
I am trying to use auto commit and transactions.But the problem I am facing is it is not rollbacking the data if any exception is raised.

 
------------------------------------------------------------------------------------------------------------------------

public class HbasePhoenixMainApp {

public static void main(String[] args) throws SQLException {

Connection connection = null;

Statement st = null;

Properties connectionProps = new Properties();

connectionProps.put("phoenix.connection.autoCommit", "true");//only client
connectionProps.put("phoenix.transactions.enabled", "true");//only client
connection = DriverManager.getConnection("jdbc:phoenix:localhost:2181",connectionProps);
st = connection.createStatement();
st.executeUpdate("CREATE TABLE MYTEST.MYTAB (employee_id integer not null primary key, name varchar) TRANSACTIONAL=true");
st.executeUpdate("UPSERT INTO MYTEST.MYTAB VALUES (1,'Vishal')");
st.executeUpdate("UPSERT INTO MYTEST.MYTAB VALUES (2,'Biradar')");

int c = 10/0; //here exception will be raised

st.executeUpdate("UPSERT INTO MYTEST.MYTAB VALUES (3,'India')");

}//main method closed
} // class is closed
---------------------------------------------------------------------


As I am using auto-commit thats why i am not doing any connection.commit() explicitly.
It must be committed automatically.
So it must rollback all the above data insert operations but actually it is inserting above two data insert operations.
But I need that it must rollback all the operations.
Is this is the right approach ??

Gokul Gunasekaran

unread,
Jul 6, 2017, 4:04:07 PM7/6/17
to Vishal Biradar, Tephra User
Vishal,

I see that you have opened a TEPHRA JIRA regarding this issue (https://issues.apache.org/jira/browse/TEPHRA-237). We can continue the conversation there. Also, as you might have noticed Tephra is now under incubation in ASF.  So you can send your questions/comments to d...@tephra.incubator.apache.org.

Thanks,
Gokul

--
You received this message because you are subscribed to the Google Groups "Tephra User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tephra-user...@googlegroups.com.
To post to this group, send email to tephr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tephra-user/1fe612a7-3cee-4669-98e1-f06a0f594226%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Poorna Chandra

unread,
Jul 6, 2017, 4:10:13 PM7/6/17
to Vishal Biradar, d...@tephra.incubator.apache.org


Moving the discussion to d...@tephra.incubator.apache.org so that someone who has more context on how Phoenix auto commit works can chime in.

Poorna.

To unsubscribe from this group and stop receiving emails from it, send an email to tephra-user+unsubscribe@googlegroups.com.

To post to this group, send email to tephr...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tephra-user/1fe612a7-3cee-4669-98e1-f06a0f594226%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Tephra User" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tephra-user+unsubscribe@googlegroups.com.

To post to this group, send email to tephr...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages