java从外部得到数据,从Web容器外部访问数据源(通过JNDI)

I'm trying to access a data source that is defined within a web container (JBoss) from a fat client outside the container.

I've decided to look up the data source through JNDI. Actually, my persistence framework (Ibatis) does this.

When performing queries I always end up getting this error:

java.lang.IllegalAccessException: Method=public abstract java.sql.Connection java.sql.Statement.getConnection() throws java.sql.SQLException does not return Serializable

Stacktrace:

org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.doStatementMethod(WrapperDataSourceS

ervice.java:411),

org.jboss.resource.adapter.jdbc.remote.WrapperDataSourceService.invoke(WrapperDataSourceService.java

:223),

sun.reflect.GeneratedMethodAccessor106.invoke(Unknown Source),

sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25),

java.lang.reflect.Method.invoke(Method.java:585),

org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155),

org.jboss.mx.server.Invocation.dispatch(Invocation.java:94),

org.jboss.mx.server.Invocation.invoke(Invocation.java:86),

org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264),

org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659),

My Datasource:

jdbc/xxxxxDS

jdbc:oracle:thin:@xxxxxxxxx:1521:xxxxxxx

false

oracle.jdbc.driver.OracleDriver

xxxxxxxx

xxxxxx

org.jboss.resource.adapter.jdbc.vendor.OracleExceptionSorter

5

20

Does anyone have a clue where this could come from?

Maybe someone even knows a better way how to achieve this.

Any hints are much appreciated!

Cheers,

Michael

解决方案

@Michael Well, java.sql.Connection is an Interface - it might technically be possible for the concrete implementation you're getting from JBoss to be Serializable - but I don't think you're really going to have any options you can use. If it was possible, it would probably be easy :)

I think @toolkit might have said the right words with useable outside the VM - the JDBC drivers will be talking to native driver code running in the underlying OS I guess, so that might explain why you can't just pass a connection over the network elsewhere.

My advice, (if you don't get any better advice!) would be to find a different approach - if you have access to locate the resource on the JBoss directory, maybe implement a proxy object that you can locate and obtain from the directory that allows you to use the connection remotely from your fat client. That's a design pattern called data transfer object I think Wikipedia entry

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值