如何声明 GlassFish 的数据源?
我知道如何使用 JBoss 执行此操作:创建一个 *-ds.xml
文件,并将其放入我的 deploy
目录中。
- 是否有一种声明性方法可以对 GlassFish (v3.1) 执行相同的操作?
- 我是否以错误的方式思考这个问题? (参见下一个问题)
- 是否有一种更玻璃鱼般的方式让我的 Java EE 应用程序与数据库对话?
其他可能相关的信息:
- 我想连接到 SQL Server 2008 数据库
- 我正在使用 Eclipse + GlassFish 服务器工具
- 我对 GlassFish 几乎一无所知。我对 JBoss 比较熟悉
I know how I'd do this using JBoss: create a *-ds.xml
file, and drop it into my deploy
directory.
- Is there a declarative way to do the same with GlassFish (v3.1)?
- Am I thinking about this the wrong way? (See next question)
- Is there a more-Glassfishy way to get my Java EE application to talk to a database?
Other potentially-revelant info:
- I want to connect to a SQL Server 2008 database
- I'm using Eclipse + GlassFish Server Tools
- I know next to nothing about GlassFish. I'm much more familiar with JBoss
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以在 EAR 的
application.xml
或ejb-jar.xml
中定义它。您甚至可以使用注释。长答案简短:Java EE 6 中的数据源资源定义。
You can define it in
application.xml
orejb-jar.xml
of your EAR. You can even use annotations.Long answer short: DataSource Resource Definition in Java EE 6.
BalusC 是正确的 (+1 ),使用 Java EE 6,您可以通过注释或使用来声明数据源定义以标准和可移植的方式创建部署描述符。
如果您还对创建 JMS 资源等数据源之外的其他资源感兴趣,您还可以将
glassfish-resources.xml
文件打包为应用程序的一部分。请参阅:BalusC is right (+1), with Java EE 6 you can declare datasource definitions either through annotations or through the use of deployment descriptors in a standard and portable way.
Just in case you'd be also interested by creating other resources than datasources like JMS resources, you can also package a
glassfish-resources.xml
file as part of your application. See: