on 08-09-2010 8:15 AM
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!
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.