使用ejb创建数据源。无法解析类型java.lang.CharSequence。它是从所需的.class文件间接引用的

时间:2014-07-20 04:54:08

标签: java ejb jndi

package myJsp;

import java.sql.*;
import javax.sql.*;
import javax.ejb.*;
import javax.naming.*;

public class A implements SessionBean {   
  private static final long serialVersionUID = 1L; 
  public void ejbCreate() throws CreateException {    
    ctx = new InitialContext();
    ds = (DataSource)ctx.lookup("jdbc/fastCoffeeDB");
  }   
  public void ejbActivate() {
  }
  public void ejbPassivate() {
  }
  public void ejbRemove() {
  }
  public void setSessionContext(SessionContext ctx) {
  }  
  public void updatePrice(float price, String cofName,
                          String username, String password) throws SQLException {
    Connection con;
    PreparedStatement pstmt;
    try {
        con = ds.getConnection(username, password);
        con.setAutoCommit(false);
        System.out.println("connection successful");
        con.commit();

    } finally {
        if (con != null) con.close();
    }
  }

  private DataSource ds = null;
  private Context ctx = null;
}

我添加了javaee.jar文件并尝试为我的项目创建jndi接口。

  ds = (DataSource)ctx.lookup("jdbc/fastCoffeeDB"); 
  ------The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files.

这是什么意思?

0 个答案:

没有答案