好象是事务出了问题,看看你的事物吧,
你没写jdbc的事务吧?

解决方案 »

  1.   

    难到我编写BMP/CMP同时必须编写事务  事务不是已经委派给容器管理了么
    而且这是一个商业方法调用中出现的错误  
    在这个方法之前create成功了 数据库中已经创建了数据
      

  2.   

    Bean managed persistence
    Container managed persistence
    ----------
    用bmp自然是想自己控制事务了,否则用cmp好了
    status:'Committed'
    ----------
    连接不可用
      

  3.   

    我想问一下  连接不可用是什么概念  关闭了还是事物提交了
    No further JDBC access is allowed within this transaction.
    好象是不允许在这个事务中再调用JDBC访问? 为啥呢?我自己控制事务也不样 大家再提点意见吧  我晕
      

  4.   

    好像BMP中访问数据库都差不多是这种结构:
    transaction.setAutoCommit(false);
    transaction.begin();
    ……操作数据库
    ……事务完成
    transaction.commit();
    你试试看
      

  5.   

    我又试验了一下 通过远程接口调用create方法可以成功完成 连续调用几个都正常工作但是即使调用一个最简单的返回一个字段的方法也出现上面的错误
    既在调用普通方法前地先调用ejbLoad()从数据库中同步数据 在ejbLoad中调用
    PreparedStatement prepStmt = con.prepareStatement(selectStatement);就出现 No further JDBC access is allowed within this transaction.错误了救救我吧  我要疯了  试了很多办法都不行
      

  6.   

    // Source File Name:   Account.javaimport java.rmi.RemoteException;
    import javax.ejb.EJBObject;public interface Account
        extends EJBObject
    {    public abstract void debit(double d)
            throws InsufficientBalanceException, RemoteException;    public abstract void credit(double d)
            throws RemoteException;    public abstract String getFirstName()
            throws RemoteException;    public abstract String getLastName()
            throws RemoteException;    public abstract double getBalance()
            throws RemoteException;
    }
    // Source File Name:   AccountHome.javaimport java.rmi.RemoteException;
    import java.util.Collection;
    import javax.ejb.*;public interface AccountHome
        extends EJBHome
    {    public abstract Account create(String s, String s1, String s2, double d)
            throws RemoteException, CreateException;    public abstract Account findByPrimaryKey(String s)
            throws FinderException, RemoteException;    public abstract Collection findByLastName(String s)
            throws FinderException, RemoteException;    public abstract Collection findInRange(double d, double d1)
            throws FinderException, RemoteException;
    }
      

  7.   

    // Source File Name:   AccountEJB.javaimport java.io.PrintStream;
    import java.sql.*;
    import java.util.ArrayList;
    import java.util.Collection;
    import javax.ejb.*;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.sql.DataSource;public class AccountEJB
        implements EntityBean
    {    private String id;
        private String firstName;
        private String lastName;
        private double balance;
        private EntityContext context;
        private Connection con;
        private String dbName;    public AccountEJB()
        {
            dbName = "jdbc/AccountDB";
        }    public void debit(double d)
            throws InsufficientBalanceException
        {
            System.out.println("debit");
            if(balance - d < 0.0D)
            {
                throw new InsufficientBalanceException();
            } else
            {
                balance -= d;
                return;
            }
        }    public void credit(double d)
        {
            System.out.println("credit");
            balance += d;
        }    public String getFirstName()
        {
            System.out.println("getFirstName");
            return firstName;
        }    public String getLastName()
        {
            System.out.println("getLastName");
            return lastName;
        }    public double getBalance()
        {
            System.out.println("getBalance");
            return balance;
        }    public String ejbCreate(String s, String s1, String s2, double d)
            throws CreateException
        {
            System.out.println("ejbCreate");
            if(d < 0.0D)
                throw new CreateException("A negative initial balance is not allowed.");
            try
            {
                insertRow(s, s1, s2, d);
            }
            catch(Exception exception)
            {
                throw new EJBException("ejbCreate: " + exception.getMessage());
            }
            id = s;
            firstName = s1;
            lastName = s2;
            balance = d;
            return s;
        }    public String ejbFindByPrimaryKey(String s)
            throws FinderException
        {
            System.out.println("ejbFindByPrimaryKey");
            boolean flag;
            try
            {
                flag = selectByPrimaryKey(s);
            }
            catch(Exception exception)
            {
                throw new EJBException("ejbFindByPrimaryKey: " + exception.getMessage());
            }
            if(flag)
                return s;
            else
                throw new ObjectNotFoundException("Row for id " + s + " not found.");
        }    public Collection ejbFindByLastName(String s)
            throws FinderException
        {
            System.out.println("ejbFindByLastName");
            Collection collection;
            try
            {
                collection = selectByLastName(s);
            }
            catch(Exception exception)
            {
                throw new EJBException("ejbFindByLastName " + exception.getMessage());
            }
            if(collection.isEmpty())
                throw new ObjectNotFoundException("No rows found.");
            else
                return collection;
        }    public Collection ejbFindInRange(double d, double d1)
            throws FinderException
        {
            System.out.println("ejbFindInRagnge");
            Collection collection;
            try
            {
                collection = selectInRange(d, d1);
            }
            catch(Exception exception)
            {
                throw new EJBException("ejbFindInRange: " + exception.getMessage());
            }
            if(collection.isEmpty())
                throw new ObjectNotFoundException("No rows found.");
            else
                return collection;
        }    public void ejbRemove()
        {
            System.out.println("ejbRemove");
            try
            {
                deleteRow(id);
            }
            catch(Exception exception)
            {
                throw new EJBException("ejbRemove: " + exception.getMessage());
            }
        }    public void setEntityContext(EntityContext entitycontext)
        {
            System.out.println("setEntityContext");
            context = entitycontext;
            try
            {
                makeConnection();
            }
            catch(Exception exception)
            {
                throw new EJBException("Unable to connect to database. " + exception.getMessage());
            }
        }    public void unsetEntityContext()
        {
            System.out.println("unsetEntityContext");
            try
            {
                con.close();
            }
            catch(SQLException sqlexception)
            {
                throw new EJBException("unsetEntityContext: " + sqlexception.getMessage());
            }
        }    public void ejbActivate()
        {
            System.out.println("ejbActivate");
            id = (String)context.getPrimaryKey();
        }    public void ejbPassivate()
        {
            System.out.println("ejbPAssivate");
            id = null;
        }    public void ejbLoad()
        {
            System.out.println("ejbLoad");
            try
            {
                loadRow();
            }
            catch(Exception exception)
            {
                throw new EJBException("ejbLoad: " + exception.getMessage());
            }
        }    public void ejbStore()
        {
            System.out.println("ejbStore");
            try
            {
                storeRow();
            }
            catch(Exception exception)
            {
                throw new EJBException("ejbLoad: " + exception.getMessage());
            }
        }    public void ejbPostCreate(String s, String s1, String s2, double d)
        {
            System.out.println("ejbPostCreate");
        }