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("successful 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.
关于安装jboss3 Tomcat4 mysql的学习及相关资料 文章结束,如果您想详细了解是什么意思,怎么使用?请进入 bbs.ccidu.com 为您详细解答!
|