cancel
Showing results for 
Search instead for 
Did you mean: 

This resource participates in a JTA transaction

Former Member
0 Kudos

Hi ,everybody,please help me solve the following question:

com.sap.engine.services.dbpool.exceptions.BaseSQLException: Cannot commit JDBC transaction from this connection of "mysqlds" DataSource. This resource participates in a JTA transaction.

Thank you!

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Try to explain your scenario with more details.

Example:

- Are you using EJB? This EJB is CMT, BMT? How is defined the Transaction for your methods?

Best regards

Former Member
0 Kudos

Hi,Isaias Cristian Barroso.Thank you for your answer,These are my codes in the EJB in the follow.Please help me,Thank you!

public class DBConnection {

private static final String DATABASE_JNDI_PROVIDER = "com.sap.engine.services.jndi.InitialContextFactoryImpl";

public static Connection getConnection() throws Exception {

try {

Connection conn = null;

java.util.Properties properties = null;

properties = new java.util.Properties();

properties.put(Context.INITIAL_CONTEXT_FACTORY,

DATABASE_JNDI_PROVIDER);

InitialContext jndiCntx = new InitialContext(properties);

DataSource ds = (DataSource) jndiCntx.lookup("jdbc/mysqlAS");

conn = ds.getConnection();

return conn;

} catch (Exception e) {

e.printStackTrace();

}

}

/**

  • Session Bean implementation class PersonManager

*/

@WebService(endpointInterface="com.thitech.personmanager.PersonManagerRemote", portName="PersonManagerPort", serviceName="PersonManagerService",

targetNamespace="http://thitech.com/personmanager/")

@Stateless

public class PersonManager implements PersonManagerRemote, PersonManagerLocal {

/**

  • Default constructor.

*/

public PersonManager() {

// TODO Auto-generated constructor stub

}

@Override

public String insertPerson(int personId, String name, String sex, int age,

String email, String address) {

PersonInfo pi = new PersonInfo();

ArrayList list = new ArrayList();

PreparedStatement pstm = null;

Connection conn =null;

String returnType=null;

try {

conn = DBConnection.getConnection();

conn.setAutoCommit(false);

String sql = "insert into personinfo values(?,?,?,?,?,?)";

pstm=conn.prepareStatement(sql);

pstm.setInt(1, personId);

pstm.setString(2, name);

pstm.setString(3, sex);

pstm.setInt(4, age);

pstm.setString(5, email);

pstm.setString(6, address);

pstm.executeUpdate();

conn.commit();

returnType="success";

} catch (Exception e) {

e.printStackTrace();

} finally {

if (pstm != null) {

try {

pstm.close();

} catch (SQLException e) {

e.printStackTrace();

}

}

DBConnection.closeConnection(conn);

}

return returnType;

}

Best regards

Former Member
0 Kudos

Hi,

You did mark the question as Answered, your problem was solved?

Best regards

Former Member
0 Kudos

Hi,Isaias Cristian Barroso

I have not solved this question.

Best Regards

Former Member
0 Kudos

Hi,

Try to remove the commit of your code, you are on a EJB with CMT.

Execute this test and post the result.

Best regards

Former Member
0 Kudos

Hi,Isaias Cristiano Barroso

Thank You! My Issue is solved

Best regards