安裝jboss3+Tomcat4+mysql

發表于:2007-06-21來源:作者:點擊數: 標簽:
1.從網上下載j boss 3+ Tomcat 4的安裝包,最好不要單獨下載,因為集成比較麻煩。 2.解開安裝包即可,并設置JDK的運行環境,%JAVA_HOME%環境變量,一般不需要修改JBOSS配置,即可啟動。 3.從www.mysql.org下載mysql的jdbc的驅動程序,不要下載3的版本,無法

   
  1.從網上下載jboss3+Tomcat4的安裝包,最好不要單獨下載,因為集成比較麻煩。
2.解開安裝包即可,并設置JDK的運行環境,%JAVA_HOME%環境變量,一般不需要修改JBOSS配置,即可啟動。

3.從www.mysql.org下載mysql的jdbc的驅動程序,不要下載3的版本,無法使用有問題,請下載2.0.14的版本驅動。
4.將該驅動拷貝到:JBOSS安裝目錄serverdefaultlib 下。將 JBOSS安裝目錄docsexamplesjca 下的文件:mysql-service.xml
拷貝到JBOSS安裝目錄serverdefaultdeploy 目錄下。 準備修改以下四個文件:

JBOSS安裝目錄serverdefaultdeploymysql-service.xml

<attribute name="JndiName">MySqlDS</attribute>

<attribute name="ManagedConnectionFactoryProperties">
<properties>
<config-property name="ConnectionURL" type="java.lang.String">jdbc:mysql://mysql服務器的IP地址:3306/數據庫名</config-property>
<config-property name="DriverClass" type="java.lang.String">com.mysql.jdbc.Driver</config-property>
<!--set these only if you want only default logins, not through JAAS -->
<config-property name="UserName" type="java.lang.String">輸入你的用戶名</config-property>
<config-property name="Password" type="java.lang.String">輸入你的密碼</config-property>
</properties>

</attribute>

JBOSS安裝目錄serverdefaultconfstandardjbosscmp-jdbc.xml

<jbosscmp-jdbc>

<defaults>
<datasource>java:/MySqlDS</datasource>
<datasource-mapping>mySQL</datasource-mapping>

JBOSS安裝目錄serverdefaultconfstandardjaws.xml

<jaws>
<datasource>java:/MySqlDS</datasource>
<type-mapping>mySQL</type-mapping>
<debug>false</debug>

JBOSS安裝目錄serverdefaultconflogin-config.xml

<application-policy name = "MySqlDbRealm">
<authentication>
<login-module code = "org.jboss.resource.security.ConfiguredIdentityLoginModule" flag = "required">
<module-option name = "principal">root</module-option>
<module-option name = "userName">輸入你的用戶名</module-option>
<module-option name = "password">輸入你的密碼</module-option>
<module-option name = "managedConnectionFactoryName">jboss.jca:service=LocalTxCM,name=MySqlDS</module-option>
</login-module>
</authentication>
</application-policy>

5.重新啟動系統
6.建立測試程序

<%@ page contentType="text/html;charset=gb2312" %>

<%@ page import="java.sql.*, javax.sql.DataSource, javax.naming.InitialContext" %>

<%

InitialContext jct = new InitialContext();
DataSource ds = (DataSource)jct.lookup("java:/MySqlDS");
System.out.println("suclearcase/" target="_blank" >ccessful find MySqlDS");
Connection conn = ds.getConnection();
/*
Class.forName("com.mysql.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/mysql","root","mysql");
*/

Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("select * from user");
while (rs.next()) {
out.println( rs.getString("User") + "<br>");
}
conn.close();

7.一切OK.

原文轉自:http://www.anti-gravitydesign.com

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97