在Glassfish中制作数据源 [英] Making datasource in Glassfish

查看:106
本文介绍了在Glassfish中制作数据源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用服务器的管理控制台为GlassFish创建一个JDBC连接池资源。



创建池的页面上的一个字段标记为Resource类型'。该字段有四个可能的值:javax.sql.DataSource,javax.sql.XADataSource,javax.sql.ConnectionPoolDataSource和javax.sql.Driver,但创建JDBC连接池向导的帮助文本没有太多的信息这些选择的优缺点。



当提示选择我应该选择的资源类型时?

我要连接到本地的MySQL服务器。最好能够解释下拉选项之间的差异。

解决方案

以下是您需要的场景列出的每种资源类型。希望这有帮助。
$ b $ p $ DataSource DataSource一个DataSource对象是Connection对象的一个​​工厂。当使用简单的DataSource时,appserver使用自己的池而不是native。



ConnectionPoolDataSource
ConnectionPoolDataSource对象是PooledConnection对象的工厂。 ConnectionPoolDataSource用于访问通过JDBC驱动程序实现本地池的PooledConnection。在这种情况下,应用程序服务器可以使用此本机接口实现连接池。请参阅 Java API 以了解PooledConnection是什么。 .. ConnectionPoolDataSource可以使用第三方实现进行池化 - 就我所知的Tomcat而言,例如,使用DBCP连接池。



XADataSource
如果要执行分布式事务,则需要XADataSource。如果应用程序使用XADataSource而不是DataSource



  • 使用Java Transaction API(JTA)

  • 在单个事务中包含多个数据库更新
  • 在事务处理期间访问多个资源(例如数据库和Java消息传递服务(JMS))

  • ul>

    I am creating a JDBC connection pool resource for GlassFish, using the server's Admin Console.

    One of the fields on the page to create the pool is labeled 'Resource Type'. This field has four possible values: javax.sql.DataSource, javax.sql.XADataSource, javax.sql.ConnectionPoolDataSource and javax.sql.Driver, but the help text for the Create JDBC connection pool 'wizard' does not have much info about the advantages and disadvantages of these choices.

    When prompted to pick a resource type which should I choose?

    I am going to connect to a local MySQL server. It would be nice to get an explanation of the differences between the choices in the drop-down as well.

    解决方案

    Below are the scenarios where you would need each of the resource types listed. Hope this helps.

    DataSource DataSource A DataSource object is a factory for Connection objects. When using simple DataSource, appserver uses its own pooling instead of native.

    ConnectionPoolDataSource A ConnectionPoolDataSource object is a factory for PooledConnection objects. ConnectionPoolDataSource is used to give access to PooledConnection which implements native pooling by JDBC driver. In this case application server can implement connections pooling using this native interface. Please refer to Java API to know what a PooledConnection is...A ConnectionPoolDataSource can use a third party implementation for pooling - as far as I know for Tomcat, for instance, DBCP connection pooling is used.

    XADataSource You need an XADataSource if you want to execute a Distributed Transaction. You should use XADataSource instead of DataSource if the application

    • Uses the Java Transaction API (JTA)
    • Includes multiple database updates within a single transaction
    • Accesses multiple resources, such as a database and the Java Messaging Service (JMS), during a transaction

    这篇关于在Glassfish中制作数据源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆