我在ejb-jar.xml中也声明了数据库引用
 <resource-ref>
            <res-ref-name>jdbc/People</res-ref-name>
            <res-type>javax.sql.DataSource</res-type>
            <res-auth>Container</res-auth>
            <res-sharing-scope>Shareable</res-sharing-scope>
      </resource-ref>

解决方案 »

  1.   

    <datasource-mapping>MS SQLSERVER2000</datasource-mapping>MyDatabase = JavaProject
      

  2.   

    参数    <user-name>x</user-name>
        <password>y</password>
    设置的是SQL Server的访问密码,程序中不需要用getConnection("x","y");
    应该是getConnection()
    你有SQL Server的驱动程序吗?为什么用odbc
      

  3.   

    <datasource-mapping>在哪个文件中设置回“clarck3000(j2ee)”我安装的是JDBC For SQL2000,
    还有 那参数    <user-name>x</user-name>
        <password>y</password> 是不是没有作用?不然为什么要使用getConnection()
    而不使用
    getConnection("x","y");
      

  4.   

    我按照上面两位兄弟说的进行修改,运行的时候还是提示说 Table not Found....
    证明还是数据源没有配置好,
      

  5.   

    jboss3.2.3?
    1.mssql-ds.xml的例子是:
    <datasources>
      <local-tx-datasource>
        <jndi-name>People</jndi-name>
        <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=JavaProject</connection-url>
        <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
        <user-name>用户名</user-name>
        <password>密码</password>
         
      </local-tx-datasource></datasources>
    2.default\conf\standardjbosscmp-jdbc.xml
    <defaults>
          <datasource>java:/People</datasource>
          <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
      

  6.   

    jboss-3.2.3\docs\examples\jca底下有各个数据库的配置文件,找到mssql-ds.xml,修改成你想要的,然后拷贝到jboss-3.2.3\server\default\deploy底下,就可以了。
      

  7.   

    1 将jdbc for sqlserver 2000的三个jar文件拷贝到jboss-3.2.x\server\default\lib下面
    2 修改jca下面的mssql-ds.xml,然后拷贝到jboss-3.2.x\server\default下面,内容大致如下:
    <local-tx-datasource>
        <jndi-name>MSSQLDS</jndi-name>
        <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=devTest</connection-url>
        <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
        <user-name>sa</user-name>
        <password>sa</password>
            <!-- sql to call when connection is created
            <new-connection-sql>some arbitrary sql</new-connection-sql>
            -->        <!-- sql to call on an existing pooled connection when it is obtained from pool 
            <check-valid-connection-sql>some arbitrary sql</check-valid-connection-sql>
            -->  </local-tx-datasource>
    3 修改conf下面的standardjbosscmp-jdbc.xml的default部分
    <defaults>
          <datasource>java:/MSSQLDS</datasource>
          <datasource-mapping>MS SQLSERVER2000</datasource-mapping>
    其中MSSQLDS就是2设置的JNDI名称,如果不修改,在做ENTITY映射的时候和可能到jboss自带的数据库中
    然后如果要是写bmp或者通用类的时候就是
    try
          {
             Context jndiCntx = new InitialContext ();
             DataSource ds =
             (DataSource)jndiCntx.lookup ("java:/MSSQLDS"); //(最好通过comp env)        
             return ds.getConnection ();
          }
          catch (NamingException ne)
          {
             throw new EJBException (ne);
          }
      

  8.   

    我就是象 fingertiploneliness(指尖寂寞) 说的做的
    唯一的不同就是我的jdbc驱动程序不是jar文件,而是一个exe程序(从微软网站上下的),我搜索 SQL Server 2000 Driver for JDBC结果都是那个exe程序,没有是jar文件的啊
      

  9.   

    我在\Program Files\Microsoft SQL Server 2000 Driver for JDBC\lib 里找到了那三个jar文件,把他们放到了jboss-3.2.x\server\default\lib下面下面,运行失败
    我又把这三个jar添加到classpath中,也还是运行失败,
    我是在会话bean,和实体bean中测试都失败
    会话bean中的代码是            InitialContext initialcontext = new InitialContext();
                ds = (DataSource)initialcontext.lookup("java:comp/env/jdbc/People");
     我的mssql-ds.xml是
                <jndi-name>People</jndi-name>
        <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=JavaProject</connection-url>
        <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
        <user-name>x</user-name>
        <password>y</password>standardjbosscmp-jdbc.xml的default部分是
          <datasource>java:/People</datasource>
          <datasource-mapping>MS SQLSERVER2000</datasource-mapping>是不是 ds = (DataSource)initialcontext.lookup("java:comp/env/jdbc/People");有问题?
      

  10.   

    终于找到问题所在了,
    果然是lookup("java:comp/env/jdbc/People");不正确
    改为
    lookup("java:/People");
    就能找到数据源
    但是连接的时候提示: 用户x登陆失败,原因:未与信任SQL Server连接相关联
    我的设置
    <user-name>x</user-name>
        <password>y</password>
    我连接的时候
     用con=ds.getConnection();
    和   con=ds.getConnection("x","y");都试过,都提示错误然后我修改<user-name>*</user-name>
        <password>*</password>
    同样用con=ds.getConnection();
    和   con=ds.getConnection("x","y");连接还是提示错误。
      

  11.   

    这是你安装sql server的登录方式的问题,你在sql server的安全设置更改就ok了
      

  12.   

    我在sql server的“安全性\登陆” 设置里新建了用户 ejb 使用"sql server身份登陆"
    同时还设置了此登陆可以访问的数据库和默认数据库为 JavaProject
    同时修改mssql-ds.xml为
    <jndi-name>People</jndi-name>
        <connection-url>jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=JavaProject</connection-url>
        <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class>
        <user-name>ejb</user-name>
        <password>12345678</password>设置好后,重新启动服务器,运行以后还是有问题(还是说未信任的sql连接)
    我在会话bean中使用  con=ds.getConnect();和 getConnect("ejb","12345678")
    都还是有错误,
    请问 lyneville(心佛) ,是不是还是我的 sql server的用户设置有问题,还是其他什么问题?
      

  13.   

    你的操作系统是什么?
    如果是2003的话,
    sqlserver必须打上sp3的补丁
      

  14.   

    在你的sql server的服务器属性中,设置为sql server与windows登陆方式就可以了.不是新建用户.
      

  15.   

    <?xml version="1.0" encoding="UTF-8" ?> 
    - <!--  ===================================================================== 
      --> 
    - <!--                                                                        
      --> 
    - <!--   JBoss Server Configuration                                           
      --> 
    - <!--                                                                        
      --> 
    - <!--  ===================================================================== 
      --> 
    - <server>
    - <!--  ======================================================================
      --> 
    - <!--  New ConnectionManager setup for Microsoft SQL Server 2000  driver     
      --> 
    - <!--  You may download the latest Microsoft JDBC driver from *Microsoft*    
      --> 
    - <!--  http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/MSDN-FILES/027/001/779/msdncompositedoc.xml&frame=true 
      --> 
    - <!--  Build jmx-api (build/build.sh all) and view for config documentation  
      --> 
    - <!--  ===================================================================== 
      --> 
    - <mbean code="org.jboss.resource.connectionmanager.LocalTxConnectionManager" name="jboss.jca:service=LocalTxCM,name=MSSQLDS">
    - <!-- 
     Include a login module configuration named MSSQLDbRealm. 
             Update your login-conf.xml, here is an example for a 
             ConfiguredIdentityLoginModule:    <application-policy name = "MSSQLDbRealm">
           <authentication>
              <login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
                 <module-option name = "principal">yourprincipal</module-option>
                 <module-option name = "userName">yourusername</module-option>
                 <module-option name = "password">yourpassword</module-option>
                 <module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MSSQLDS</module-option>
              </login-module>
           </authentication>
        </application-policy>    NOTE: the application-policy name attribute must match SecurityDomainJndiName, and the 
          module-option name = "managedConnectionFactoryName"
        must match the object name of the ConnectionManager you are configuring here.
          --> 
    - <!-- 
    uncomment out this line if you are using the MSSQLDbRealm above
        <attribute name="SecurityDomainJndiName">MSSQLDbRealm</attribute>
          --> 
    - <depends optional-attribute-name="ManagedConnectionFactoryName">
    - <!-- embedded mbean
      --> 
    - <mbean code="org.jboss.resource.connectionmanager.RARDeployment" name="jboss.jca:service=LocalTxDS,name=MSSQLDS">
      <attribute name="JndiName">DefaultDS</attribute> 
    - <attribute name="ManagedConnectionFactoryProperties">
    - <properties>
      <config-property name="ConnectionURL" type="java.lang.String">jdbc:microsoft:sqlserver://XXX.XXX.XXX.XXX:1433;DatabaseName=yourDatabase</config-property> 
      <config-property name="DriverClass" type="java.lang.String">com.microsoft.jdbc.sqlserver.SQLServerDriver</config-property> 
    - <!-- set these only if you want only default logins, not through JAAS
      --> 
      <config-property name="UserName" type="java.lang.String">YourUserName</config-property> 
      <config-property name="Password" type="java.lang.String">YourPasswd</config-property> 
      </properties>
      </attribute>
    - <!-- Below here are advanced properties 
      --> 
    - <!-- hack
      --> 
      <depends optional-attribute-name="OldRarDeployment">jboss.jca:service=RARDeployment,name=JBoss LocalTransaction JDBC Wrapper</depends> 
      </mbean>
      </depends>
    - <depends optional-attribute-name="ManagedConnectionPool">
    - <!-- embedded mbean
      --> 
    - <mbean code="org.jboss.resource.connectionmanager.JBossManagedConnectionPool" name="jboss.jca:service=LocalTxPool,name=MSSQLDS">
      <attribute name="MinSize">0</attribute> 
      <attribute name="MaxSize">50</attribute> 
      <attribute name="BlockingTimeoutMillis">5000</attribute> 
      <attribute name="IdleTimeoutMinutes">15</attribute> 
    - <!-- 
    criteria indicates if Subject (from security domain) or app supplied
                parameters (such as from getConnection(user, pw)) are used to distinguish
                connections in the pool. Choices are 
                ByContainerAndApplication (use both), 
                ByContainer (use Subject),
                ByApplication (use app supplied params only),
                ByNothing (all connections are equivalent, usually if adapter supports
                  reauthentication)  --> 
      <attribute name="Criteria">ByContainer</attribute> 
      </mbean>
      </depends>
      <depends optional-attribute-name="CachedConnectionManager">jboss.jca:service=CachedConnectionManager</depends> 
      <depends optional-attribute-name="JaasSecurityManagerService">jboss.security:service=JaasSecurityManager</depends> 
      <attribute name="TransactionManager">java:/TransactionManager</attribute> 
    - <!-- make the rar deploy! hack till better deployment
      --> 
      <depends>jboss.jca:service=RARDeployer</depends> 
      </mbean>
      </server>
      

  16.   

    MyDatabase是你数据库的名字,查查你SQL Server Enterprise,里用什么名的
    不是数据源名哦
    JNDI者是是你要引用的数据源名