2016-08-16 11 views
0

私はjspプロジェクトをtomcatにアップロードしようとしています。JSPエラーのクラスをコンパイルできません。tomcat、mysql

下の画像は、私のjspプロジェクトの構造です。

enter image description here

とinsert.htmlの機能を呼び起こすエラーの下で、insert.jspを使用しようとして。

このコードは、mysqlサーバーにのみデータを挿入します。

enter image description here

DBConnection.java:

package com.exam; 

import java.sql.*; 

public class DBConnection { 

    public static Connection getCon() throws SQLException { 
     // TODO Auto-generated method stub 

     Connection con = null; 
     try{ 
      Class.forName("com.mysql.jdbc.Driver"); 
      String url="jdbc:mysql://localhost:3306/testdb"; 
      con=DriverManager.getConnection("url", "root", "kcclab"); 
      System.out.println("DB 연결 완료"); 
      con.close(); 
      return con; 
     } 
     catch(ClassNotFoundException cnfe){ 
      System.out.println("연결이 안되네요..."+cnfe.getMessage()); 
      return null; 
     } 

    } 

} 

insert.jspを:

<%@page import="java.sql.SQLException" %> 
<%@page import="java.sql.PreparedStatement" %> 
<%@page language="java" contentType="text/html; charset=euc-kr" 
pageEncoding="euc-kr" %> 
<%@page import="java.sql.Connection" %> 
<%@page import="com.exam.DBConnection" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr"> 
<title>Insert title here</title> 
</head> 
<body> 
<% 
    request.setCharacterEncoding("euc-kr"); 
    String id=request.getParameter("ID"); 
    String pwd=request.getParameter("pwd"); 

    Connection con=null; 
    PreparedStatement pstmt=null; 
    String sql="insert into members vlaues(?,?,sysdate)"; 
    int n=0; 

    try{ 
     con=DBConnection.getCon(); 
     pstmt=con.prepareStatement(sql); 
     pstmt.setString(1, id); 
     pstmt.setString(2, pwd); 

     n=pstmt.executeUpdate(); 
    } 
    catch(SQLException se){ 
     System.out.println(se.getMessage()); 
    } 
    finally{ 
     try{ 
      if(pstmt!=null) pstmt.close(); 
      if(con!=null) con.close(); 
     } 
     catch(SQLException se){ 
      System.out.println(se.getMessage()); 
     } 
    } 
%> 
<script type="text/javascript"> 
    if(<%=n%>>0){ 
     alert("���������� ȸ�����ԵǾ����ϴ�."); 
     location.href="../index.html"; 
    } 
    else{ 
     alert("ȸ�����Կ� �����߽��ϴ�."); 
     history.go(-1); 
    } 
</script> 
</body> 
</html> 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
"http://www.w3.org/TR/html4/loose.dtd"> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr"> 
<title>Insert title here</title> 
<style type="text/css"> 
    #regbox{width:300px;} 
    #regbox label{display:block; width:100px; float:left; } 
</style> 
</head> 
<body> 
<form method="post" action="insert.jsp"> 
    <fieldset id="regbox"> 
     <legend>ȸ������</legend> 
     <label for="id">���̵�</label> 
     <input type="text" name="id"/><br/> 
     <label for="pwd">��й�ȣ</label> 
     <input type="password" name="pwd"/><br/> 
     <input type="submit" value="����"> 
     <input type="reset" value="���"/> 
    </fieldset> 
</form> 
</body> 
</html> 

insert.htmlどのように私はこのエラーを回避することはできますか?

+0

'com.exam.DBConnection'はクラスパスにありますか? –

答えて

1

これは、クラスパスの下に存在しないクラスをインポートしようとしているときに発生する可能性があります。 あなたはtomcatを見てください。webappsディレクトリ?? ファイルDBConnection.classは、WEB-INF/classesフォルダの下に存在しない場合があります。

関連する問題