Home Database Mysql Tutorial JBOSS4 数据源配置大全(一)_MySQL

JBOSS4 数据源配置大全(一)_MySQL

Jun 01, 2016 pm 01:54 PM
develop database data source article

Jboss 4.0的开发人员版本是一个开源的应用服务器,他把HypersonicDB作为他的缺省数据库。然而,开发人员也许还要使用除了HypersonicDB以外其他种类的数据库,在这篇文章中我们将看到如何在Jboss上配置使用其他的数据库。

简介

Jboss4.0使用了JDBC配置文件来配置数据库连接,它为EJB和其它J2EE应用提供了数据源(data source)进行访问。如果你要使用HypersonicDB以外的数据库你就要修改这个配置文件。这篇文章将着重讲解下面的几个部分:


Jboss的EJB部署描述符

Oralce数据库的配置

MySQL数据库的配置

Sysbase数据库的配置

DB2数据库的配置

Infomix数据库的配置

Jboss的EJB部署描述符

standardjaws.xml (位于X:/jboss4/server/default/conf)是一个映射CMP 实体EJB的标准部署描述文件。它用于配置CMP实体EJB,你也可以使用jaws.xml代替。你可以把这个文件copy到ejb .jar文件中的META-INF目录下。这个文件用于描述下面的信息:


描述一个数据源和映射类型

描述EJB映射的表

描述EJB的finder方法

描述类型映射

这里的数据源描述的是一个JNDI名称,可以通过这个JNDI来获得一个数据源连接池。Jboss4缺省的数据源使用的是HypersonicDB。如果使用其他的数据源你需要修改jaws.xml文件。

standardjbosscmp-jdbc.xml(位于X:/jboss4/server/default/conf)是配置Jboss CMP容器的标准部署描述文件,你也可以使用一个自定义的配置文件--jbosscmp-jdbc.xml来代替它。这个文件也放在EJB.jar文件的META-INF目录中。缺省使用的还是HypersonicDB作为数据库,这里也需要修改。

Oracle数据库的配置

Oracle以它的运行稳定和可靠成为了一个非常受欢迎的企业级数据库。要在Jboss 上配置使用Oracle的话我们要做的第一件事就是把Oracle的JDBC驱动程序复制到ClassPath下。我们把这个JDBC驱动程序复制到server/default/lib目录下。为了使用Oracle的事务处理数据源我们还要把/docs/examples/jca/oracle-xa-ds.xml复制到/server/default/deploy目录下。如果使用的事非事务处理的数据源,就把/docs/examples/jca/oracle-ds.xml文件复制到/server/default/deploy目录下。

下一步,我们需要修改oracle-de.xml配置文件。其中的标签和标签的设置如下:

Oracle OCI Type 2 Driver
Class: oracle.jdbc.driver.OracleDriver
URL: jdbc:oracle:oci8:@
Oracle OCI Thin Type 4 Driver
Class: oracle.jdbc.driver.OracleDriver
URL: jdbc:oracle:thin:@::
Oracle OCI XA Type 2 Driver
Class: oracle.jdbc.xa.client.OracleXADataSource
URL: jdbc:oracle:thin:@::
Oracle OCI Type 2 Driver
Class: oracle.jdbc.driver.OracleDriver
URL: jdbc:oracle:oci8:@


在Connection URL中是安装Oracle的计算机主机名,是oracle数据库的端口,是数据库名称。下一步,我们将修改standardjaws.xml 或jaws.xml配置文件,并把 和 元素这只为下面这样:


   java:/OracleDS
   Oracle8


下一步,再修改standardjbosscmp-jdbc.xml 或 jbosscmp-jdbc.xml配置文件,设置 和 元素使用Oracle。


  
      java:/OracleDS
      Oracle8
  


最后我们需要修改login-config.xml文件来使用Oracle,下面是login-config.xml文件的元素:


  
        "org.jboss.resource.security.ConfiguredIdentityLoginModule"
                            flag = "required">
         sa
         sa
        
          
                   jboss.jca:service=LocalTxCM,name=OracleDS
        

     

  


修改了oracle-ds.xml, standardjaws.xml, standardjbosscmp-jdbc.xml,和

login-config.xml 文件之后就可以再Jboss4中使用Oracle了。

MySQL数据库配置

MySQL是一个开放源代码的数据库,有很多开源项目和小型的社团都在使用它。要在Jboss4中使用MySQL的话首先要把MySQL的JDBC驱动放到CLASSPATH中。同样,把它复制到/server/default/lib目录下,再把/docs/examples/jca/mysql-ds.xml复制到/server/default/deploy目录下。修改mysql-ds.xml文件,设置为 com.mysql.jdbc.Driver再把设置为

jdbc:mysql:///,其中是数据库主机名是数据库名。

然后需要设置standardjaws.xml 或 jaws.xml文件的和元素:


  java:/MySqlDS
  mySql


同样也需要把standardjbosscmp-jdbc.xml 或 jbosscmp-jdbc.xml文件的 和 元素设置为下面这样:


   
       java:/MySqlDS
       mySql
 


最后再修改login-config.xml文件来使用MySQL:


  
        "org.jboss.resource.security.ConfiguredIdentityLoginModule"
                            flag = "required">
         sa
         sa
        
          
            jboss.jca:service=LocalTxCM,name=MySqlDS
        

     

  


修改了mysql-ds.xml, standardjaws.xml, standardjbosscmp-jdbc.xml,和

login-config.xml 文件就可以在Jboss上使用MySQL了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
1 months ago By 尊渡假赌尊渡假赌尊渡假赌
Two Point Museum: All Exhibits And Where To Find Them
1 months ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Four recommended AI-assisted programming tools Four recommended AI-assisted programming tools Apr 22, 2024 pm 05:34 PM

This AI-assisted programming tool has unearthed a large number of useful AI-assisted programming tools in this stage of rapid AI development. AI-assisted programming tools can improve development efficiency, improve code quality, and reduce bug rates. They are important assistants in the modern software development process. Today Dayao will share with you 4 AI-assisted programming tools (and all support C# language). I hope it will be helpful to everyone. https://github.com/YSGStudyHards/DotNetGuide1.GitHubCopilotGitHubCopilot is an AI coding assistant that helps you write code faster and with less effort, so you can focus more on problem solving and collaboration. Git

How does Go language implement the addition, deletion, modification and query operations of the database? How does Go language implement the addition, deletion, modification and query operations of the database? Mar 27, 2024 pm 09:39 PM

Go language is an efficient, concise and easy-to-learn programming language. It is favored by developers because of its advantages in concurrent programming and network programming. In actual development, database operations are an indispensable part. This article will introduce how to use Go language to implement database addition, deletion, modification and query operations. In Go language, we usually use third-party libraries to operate databases, such as commonly used sql packages, gorm, etc. Here we take the sql package as an example to introduce how to implement the addition, deletion, modification and query operations of the database. Assume we are using a MySQL database.

Learn how to develop mobile applications using Go language Learn how to develop mobile applications using Go language Mar 28, 2024 pm 10:00 PM

Go language development mobile application tutorial As the mobile application market continues to boom, more and more developers are beginning to explore how to use Go language to develop mobile applications. As a simple and efficient programming language, Go language has also shown strong potential in mobile application development. This article will introduce in detail how to use Go language to develop mobile applications, and attach specific code examples to help readers get started quickly and start developing their own mobile applications. 1. Preparation Before starting, we need to prepare the development environment and tools. head

Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Which AI programmer is the best? Explore the potential of Devin, Tongyi Lingma and SWE-agent Apr 07, 2024 am 09:10 AM

On March 3, 2022, less than a month after the birth of the world's first AI programmer Devin, the NLP team of Princeton University developed an open source AI programmer SWE-agent. It leverages the GPT-4 model to automatically resolve issues in GitHub repositories. SWE-agent's performance on the SWE-bench test set is similar to Devin, taking an average of 93 seconds and solving 12.29% of the problems. By interacting with a dedicated terminal, SWE-agent can open and search file contents, use automatic syntax checking, edit specific lines, and write and execute tests. (Note: The above content is a slight adjustment of the original content, but the key information in the original text is retained and does not exceed the specified word limit.) SWE-A

How does Hibernate implement polymorphic mapping? How does Hibernate implement polymorphic mapping? Apr 17, 2024 pm 12:09 PM

Hibernate polymorphic mapping can map inherited classes to the database and provides the following mapping types: joined-subclass: Create a separate table for the subclass, including all columns of the parent class. table-per-class: Create a separate table for subclasses, containing only subclass-specific columns. union-subclass: similar to joined-subclass, but the parent class table unions all subclass columns.

iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos iOS 18 adds a new 'Recovered' album function to retrieve lost or damaged photos Jul 18, 2024 am 05:48 AM

Apple's latest releases of iOS18, iPadOS18 and macOS Sequoia systems have added an important feature to the Photos application, designed to help users easily recover photos and videos lost or damaged due to various reasons. The new feature introduces an album called "Recovered" in the Tools section of the Photos app that will automatically appear when a user has pictures or videos on their device that are not part of their photo library. The emergence of the "Recovered" album provides a solution for photos and videos lost due to database corruption, the camera application not saving to the photo library correctly, or a third-party application managing the photo library. Users only need a few simple steps

An in-depth analysis of how HTML reads the database An in-depth analysis of how HTML reads the database Apr 09, 2024 pm 12:36 PM

HTML cannot read the database directly, but it can be achieved through JavaScript and AJAX. The steps include establishing a database connection, sending a query, processing the response, and updating the page. This article provides a practical example of using JavaScript, AJAX and PHP to read data from a MySQL database, showing how to dynamically display query results in an HTML page. This example uses XMLHttpRequest to establish a database connection, send a query and process the response, thereby filling data into page elements and realizing the function of HTML reading the database.

Detailed tutorial on establishing a database connection using MySQLi in PHP Detailed tutorial on establishing a database connection using MySQLi in PHP Jun 04, 2024 pm 01:42 PM

How to use MySQLi to establish a database connection in PHP: Include MySQLi extension (require_once) Create connection function (functionconnect_to_db) Call connection function ($conn=connect_to_db()) Execute query ($result=$conn->query()) Close connection ( $conn->close())

See all articles