1. Unzip and install the Jboss container and start it. Access http: // localhost: 8080/jmx-console. If it is displayed as normal, the Jboss container is successfully started.
2. If Jboss is installed in the root directory of the D Drive, enter D:/jboss/server/default/deploy and create test. war directory, because the web application needs to be deployed on Jboss for access, this is actually a simulation of the Jboss web application deployment process to generate a war package, in test. the war directory according to the jsp web application structure to establish the corresponding WEB-INF directory, establish the test file index. jsp
<% @ Page contentType = "text/html; charset = gb2312" %> <% @ page import = "java. SQL. * "%> <% @ page import =" javax. SQL. dataSource "%> <% @ page import =" javax. naming. * "%>
This is handled by connecting to the Jboss data source. RegionManager is the JDNI Name of JBoss. The Jboss data source configuration will be described later.
3. Assume that the sample database sample of DB2 has been installed on the local machine and the JBoss version is 3.2.3. Enter the D:/jboss/docs/examples/jca directory, copy db2-ds.xml to D:/jboss/server/default/deploy and edit
<datasources> <local-tx-datasource> <jndi-name>mycell</jndi-name> <connection-url>jdbc:db2:sample</connection-url> <driver-class>COM.ibm.db2.jdbc.app.DB2Driver</driver-class> <user-name>db2admin</user-name> <password>asiainfo</password> <min-pool-size>0</min-pool-size> </local-tx-datasource></datasources>
4. Ensure that the DB2 JDBC driver has been placed in the lib directory of the web application, restart JBoss, and access http: // localhost: 8080/test/index. jsp
Good luck
Note: When I start Jboss in the eclipse IDE environment and access the page with the DB2 database connection, the error no db2jdbc in java is always reported. library. path. After a long time, I found that the JDBC connection type of DB2 is incorrect. The above is type2, and then I changed it to type3. below is the data source setting of type3.
<datasources> <local-tx-datasource> <jndi-name>RegionManager</jndi-name> <connection-url>jdbc:db2:127.0.0.1:sample</connection-url> <driver-class>COM.ibm.db2.jdbc.net.DB2Driver</driver-class> <user-name>db2admin</user-name> <password>asiainfo</password> <min-pool-size>0</min-pool-size> </local-tx-datasource></datasources>