Topic: jboss中配置ejb开发sql server 出错,请高手进来帮帮忙? |
Print this page |
1.jboss中配置ejb开发sql server 出错,请高手进来帮帮忙? | Copy to clipboard |
Posted by: skyandfly Posted on: 2006-01-03 03:05 我通过下面的方法配置的: 1. 数据源的配置: 在JBoss 3.2.1中,配置数据源的步骤很简单,JBoss 3.2.1本身带了主流数据库的配置实例,于目录下:C:\jboss-3.2.1_tomcat-4.1.24\docs\examples\jca。具体使用哪个配置文件取决于目标用户的数据库。如果是SQL Server 2000,则需要使用mssql-ds.xml文件(支持本地事务)或者mssql-xa-ds.xml文件(支持全局事务);如果是Oracle 9i数据库,则需要使用oracle-ds.xml文件或者oracle-xa-ds.xml文件等。这里以SQL Server 2000为例。 首先将mssql-ds.xml文件拷贝到目录:C:\jboss-3.2.1_tomcat-4.1.24\server\default\deploy下。然后打开文件,并作如下修改: <datasources> <local-tx-datasource> <jndi-name>VSSDB</jndi-name> <connection-url>jdbc:microsoft:sqlserver://125.16.45.158:1433;DatabaseName=DDD </connection-url> <driver-class>com.microsoft.jdbc.sqlserver.SQLServerDriver</driver-class> <user-name>sa</user-name> <password>sa</password> <min-pool-size>50</min-pool-size> <max-pool-size>200</max-pool-size> </local-tx-datasource> </datasources> 其中,java:/VSSDB中的VSSDB就是mssql-ds.xml配置的数据源;而“java:/”前缀表明该命名空间只是对JBoss本身可见,即运行于JBoss外的应用是不能够使用这里定义的数据源,这一点希望注意。 如果目标J2EE应用只需要本地事务,则上述过程已经完成了Datasource的配置,同时这个配置将用于JDBC以及EJB通过JNDI使用。如果要实现EJB使用Datasource,则还需要修改位于目录:C:\jboss-3.2.1_tomcat-4.1.24\server\default\conf下的standardjbosscmp-jdbc.xml文件。比如: <jbosscmp-jdbc> <defaults> <datasource>java:/VSSDB1</datasource> <datasource-mapping>MS SQLSERVER2000</datasource-mapping> <create-table>true</create-table> <remove-table>false</remove-table> <read-only>false</read-only> <time-out>300</time-out> <pk-constraint>true</pk-constraint> <fk-constraint>false</fk-constraint> 其次,MS SQLSERVER2000中的MS SQLSERVER2000可以在该文件的其他地方找到。(如果是其他数据库,情况都是类似的) 如果应用涉及到第三方类库,比如JDBC Driver,则可以将这些JDBC Driver存放到目录下:C:\jboss-3.2.1_tomcat-4.1.24\server\default\lib。 可是我在读取数据库时且出现一下错误: 20:36:28,681 INFO [STDOUT] java.sql.SQLException: Table not found: CATEGORIES i n statement [select * from Categories] 20:36:28,691 INFO [STDOUT] at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown S ource) 20:36:28,691 INFO [STDOUT] at org.hsqldb.jdbc.jdbcPreparedStatement.<init>( Unknown Source) 20:36:28,691 INFO [STDOUT] at org.hsqldb.jdbc.jdbcConnection.prepareStateme nt(Unknown Source) 20:36:28,691 INFO [STDOUT] at org.jboss.resource.adapter.jdbc.BaseWrapperMa nagedConnection.prepareStatement(BaseWrapperManagedConnection.java:374) 20:36:28,691 INFO [STDOUT] at org.jboss.resource.adapter.jdbc.WrappedConnec tion.prepareStatement(WrappedConnection.java:217) 20:36:28,691 INFO [STDOUT] at bean.synch.OpSession.getUser(OpSession.java:1 02) 20:36:28,691 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0( Native Method) 20:36:28,691 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N ativeMethodAccessorImpl.java:39) 20:36:28,691 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo ke(DelegatingMethodAccessorImpl.java:25) 20:36:28,691 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3 24) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.StatefulSessionContainer$Contai nerInterceptor.invoke(StatefulSessionContainer.java:982) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.plugins.SecurityInterceptor.inv oke(SecurityInterceptor.java:111) 20:36:28,691 INFO [STDOUT] at org.jboss.resource.connectionmanager.CachedCo nnectionInterceptor.invoke(CachedConnectionInterceptor.java:186) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.plugins.StatefulSessionInstance Interceptor.invoke(StatefulSessionInstanceInterceptor.java:273) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.plugins.AbstractTxInterceptor.i nvokeNext(AbstractTxInterceptor.java:84) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.runWit hTransactions(TxInterceptorCMT.java:315) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.plugins.TxInterceptorCMT.invoke (TxInterceptorCMT.java:148) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.plugins.LogInterceptor.invoke(L ogInterceptor.java:191) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.plugins.ProxyFactoryFinderInter ceptor.invoke(ProxyFactoryFinderInterceptor.java:122) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.StatefulSessionContainer.intern alInvoke(StatefulSessionContainer.java:449) 20:36:28,691 INFO [STDOUT] at org.jboss.ejb.Container.invoke(Container.java :709) 20:36:28,701 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0( Native Method) 20:36:28,701 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N ativeMethodAccessorImpl.java:39) 20:36:28,701 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo ke(DelegatingMethodAccessorImpl.java:25) 20:36:28,701 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3 24) 20:36:28,701 INFO [STDOUT] at org.jboss.mx.server.ReflectedDispatcher.dispa tch(ReflectedDispatcher.java:60) 20:36:28,701 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc ation.java:62) 20:36:28,701 INFO [STDOUT] at org.jboss.mx.server.Invocation.dispatch(Invoc ation.java:54) 20:36:28,701 INFO [STDOUT] at org.jboss.mx.server.Invocation.invoke(Invocat ion.java:82) 20:36:28,701 INFO [STDOUT] at org.jboss.mx.server.AbstractMBeanInvoker.invo ke(AbstractMBeanInvoker.java:197) 20:36:28,701 INFO [STDOUT] at org.jboss.mx.server.MBeanServerImpl.invoke(MB eanServerImpl.java:473) 20:36:28,701 INFO [STDOUT] at org.jboss.invocation.jrmp.server.JRMPInvoker. invoke(JRMPInvoker.java:360) 20:36:28,701 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke0( Native Method) 20:36:28,701 INFO [STDOUT] at sun.reflect.NativeMethodAccessorImpl.invoke(N ativeMethodAccessorImpl.java:39) 20:36:28,701 INFO [STDOUT] at sun.reflect.DelegatingMethodAccessorImpl.invo ke(DelegatingMethodAccessorImpl.java:25) 20:36:28,701 INFO [STDOUT] at java.lang.reflect.Method.invoke(Method.java:3 24) 20:36:28,711 INFO [STDOUT] at sun.rmi.server.UnicastServerRef.dispatch(Unic astServerRef.java:261) 20:36:28,711 INFO [STDOUT] at sun.rmi.transport.Transport$1.run(Transport.j ava:148) 20:36:28,711 INFO [STDOUT] at java.security.AccessController.doPrivileged(N ative Method) 20:36:28,711 INFO [STDOUT] at sun.rmi.transport.Transport.serviceCall(Trans port.java:144) 20:36:28,711 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport.handleMess ages(TCPTransport.java:460) 20:36:28,711 INFO [STDOUT] at sun.rmi.transport.tcp.TCPTransport$Connection Handler.run(TCPTransport.java:701) 20:36:28,711 INFO [STDOUT] at java.lang.Thread.run(Thread.java:534) 他说找不到该表,可是这个表我已经创建了的呀! 但是当我通过这个ejb建一个表,然后在从这个表中读取数据则可以,这是怎么回事情?? |
2.Re:jboss中配置ejb开发sql server 出错,请高手进来帮帮忙? [Re: skyandfly] | Copy to clipboard |
Posted by: why Posted on: 2006-01-03 03:25 skyandfly wrote on 2006.01.01: 在读取数据库时,是怎么回事情哟??? I replied: Table not found ... isn't it clear? Please double check before you post a question. Or provide more information, e.g. source code and DB schema. skyandfly wrote on 2006.01.02: 可是我通过同样的ejb,用他创建了一个表,然后再从这个表里面读取数据则可以,这又是怎么回事情?? 20:36:28,691 INFO [STDOUT] at org.hsqldb.jdbc.jdbcUtil.throwError(Unknown Source) It's using HSQLDB. |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |