Question : what is the default directory to run jsp file from tomcat 5.5 and what directory for mysql_connector.jar file to be placed?

while running the jsp program i mentioned below, there is one error msg is diplay,

{
" The server encountered an internal error () that prevented it from fulfilling this request."

exception

org.apache.jasper.JasperException: Exception in JSP: /prepared_statement_query.jsp:56

53:      PreparedStatement pstatement = null;
54:
55:     // Load JBBC driver "com.mysql.jdbc.Driver"
56:      Class.forName("com.mysql.jdbc.Driver");
57:
58:      int updateQuery = 0;
59:      
                          }

this is the error message. i think MYSQL driver is not able to load, but i already download
mysql-connector-java-5.1.13 and paste in Tomcat 5.5\webapps\ROOT\WEB-INF\lib.

OTHERWISE PLEASE TELL ME THE SOLUTION FOR THIS ERROR MESSAGE?
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd" > 

<%@ page import="java.sql.*" %> 
<%@ page import="java.io.*" %> 

<HTML>
<HEAD>
    <TITLE>insert data using prepared statement </TITLE>
</HEAD>

<BODY bgcolor="#ffffcc">
  <font size="+3" color="green"><br>Welcome in www.roseindia.net !</font>
  <FORM action="prepared_statement_query.jsp" method="get">
    <TABLE style="background-color: #ECE5B6;" WIDTH="30%" >
    

      <TR>
	      <TH width="50%">Name</TH>
		  <TD width="50%"><INPUT TYPE="text" NAME="name"></TD>
	  </tr>
      <TR>
	     <TH width="50%">City</TH>
		 <TD width="50%"><INPUT TYPE="text" NAME="city"></TD>
	  </tr>
	  <TR>
	     <TH width="50%">Phone</TH>
		 <TD width="50%"><INPUT TYPE="text" NAME="phone"></TD>
	  </tr>
	  

	  <TR>
	      <TH></TH>
		  <TD width="50%"><INPUT TYPE="submit" VALUE="submit"></TD>
	  </tr>
   </TABLE>
<%
   String name = request.getParameter("name");
   String city = request.getParameter("city");
   String phone = request.getParameter("phone");

   /* Create string of connection url within specified 
   format with machine name, 
    port number and database name. Here machine name id 
    localhost and database name is student. */
    String connectionURL = "jdbc:mysql://localhost:3306/student";

    // declare a connection by using Connection interface 
    Connection connection = null;

    // declare object of Statement interface that uses for 
    executing sql statements.
     PreparedStatement pstatement = null;

    // Load JBBC driver "com.mysql.jdbc.Driver"
     Class.forName("com.mysql.jdbc.Driver").newInstance();

     int updateQuery = 0;
     

	 // check if the text box is empty
	 if(name!=null && city!=null && phone!=null){

		 // check if the text box having only blank spaces
	     if(name!="" && city!="" && phone!="") {

            try {
              /* Create a connection by using getConnection()
              method that takes parameters of string type 
              connection url, user name and password to connect 
		to database. */
              connection = DriverManager.getConnection
              (connectionURL, "root", "root");

              // sql query to insert values in the secified table.
              String queryString = "INSERT INTO stu_info(Name,
              Address,Phone) VALUES (?, ?, ?)";

	      /* createStatement() is used for create statement
              object that is used for 
		sending sql statements to the specified database. */
              pstatement = connection.prepareStatement(queryString);
              pstatement.setString(1, name);
			  pstatement.setString(2, city);
			  pstatement.setString(3, phone);
              updateQuery = pstatement.executeUpdate();

              if (updateQuery != 0) { %>
	           <br>
	           <TABLE style="background-color: #E3E4FA;" 
                   WIDTH="30%" border="1">
		      <tr><th>Data is inserted successfully 
                    in database.</th></tr>
		   </table>
              <%
              }
            } 
            catch (Exception ex) {
            out.println("Unable to connect to batabase.");
   

            }
            finally {
                // close all the connections.
                pstatement.close();
                connection.close();
            }
	  }
	}
%>
  </FORM>
 </body> 
</html>

Answer : what is the default directory to run jsp file from tomcat 5.5 and what directory for mysql_connector.jar file to be placed?

did you reboot tomcat?
Random Solutions  
 
programming4us programming4us