1. Change the Tomcat startup port: Modify the serverdefaultdeploytomcat4-service.xml file under the JBoss installation directory. Find Connector className = "org. apache. catalina. connector. http. HttpConnector" and change the port to the desired port number.
2. after JBoss is started, access the Tomcat port (8080 by default). If the 500 error occurs, deploy your web application, servlet and so on are packaged into * According to J2EE specifications *. war: add the generated war file to serverdefaultdeploy. JBoss will automatically deploy the file. Then, enter the corresponding path to access the file.
3. Connection Pool establishment and MySql ):
1) modify the mysql-service.xml file in docsexamplesjca under the JBoss installation directory, find config-property name = "ConnectionURL" and change the content to the appropriate network service name, such as mydql connection: jdbc: mysql: // 127.0.0.1: 3306/test), find config-property name = "UserName" and config-property name = "Password" and change it to the user name and Password of your database. Save the file and copy it to the serverdefaultdeploy directory.
2) copy the JDBC driver mm. mysql-2.0.14-bin.jar provided by mysql to the serverdefalib lib directory.
3) restart the server and establish the connection pool.
4) test:
<% @ Page contentType = "text/html;" import = "javax. ejb. *, javax. naming. *, java. rmi. *, javax. rmi. *, java. util. *, java. SQL. *, javax. SQL. * "%>
<%
Context ctx = null;
DataSource ds = null;
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Try
{
Ctx = new InitialContext ();
Ds = (DataSource) ctx. lookup ("java:/MySqlDS ");
Conn = ds. getConnection ();
String str = "select id from test. test ";
Stmt = conn. prepareStatement (str );
Rs = stmt.exe cuteQuery ();
If (rs. wasNull ())
{
Out. println ("no data ");
}
While (rs. next ())
{
Out. println (rs. getInt ("id "));
}
Rs. close ();
Stmt. close ();
Conn. close ();
}
Catch (Exception e)
{
System. out. println (e );
}
%> <% @ Page contentType = "text/html;" import = "javax. ejb. *, javax. naming. *, java. rmi. *, javax. rmi. *, java. util. *, java. SQL. *, javax. SQL. * "%>
<%
Context ctx = null;
DataSource ds = null;
Connection conn = null;
PreparedStatement stmt = null;
ResultSet rs = null;
Try
{
Ctx = new InitialContext ();
Ds = (DataSource) ctx. lookup ("java:/MySqlDS ");
Conn = ds. getConnection ();
String str = "select id from test. test ";
Stmt = conn. prepareStatement (str );
Rs = stmt.exe cuteQuery ();
If (rs. wasNull ())
{
Out. println ("no data ");
}
While (rs. next ())
{
Out. println (rs. getInt ("id "));
}
Rs. close ();
Stmt. close ();
Conn. close ();
}
Catch (Exception e)
{
System. out. println (e );
}
%>