JSP+Mysql 게시판만들기 에러..부탁드려요.
-
게시물 수정 , 삭제는 로그인 필요
원래 오라클db를 사용한 소스인데 mysql로 변경하려고 합니다.
톰캣에러는 다음과 같습니다.
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP: JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 12 in the jsp file: /jsp_example/write.jspSyntax error on token "thorws", throws expected9: return conn;10: }11: 12: String TO_DB(String str)thorws Exception13: {14: if(str==null)15: {JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 10 in the jsp file: /jsp_example/write.jspSyntax error on token "}", delete this token7: Class.forName("org.gjt.mm.mysql.Driver").newInstance();8: Connection conn=DriverManager.getConnection(url,"root","1234");9: return conn;10: }11: 12: String TO_DB(String str)thorws Exception13: {JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 54 in the jsp file: /jsp_example/write.jspSyntax error, insert "}" to complete MethodBody51: "','"+description+"')";52: stmt.executeUpdate(sql);53: stmt.close();54: }catch(SQLException e){55: }56: %>57: <html>JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 54 in the jsp file: /jsp_example/write.jspSyntax error, insert "Finally" to complete TryStatement51: "','"+description+"')";52: stmt.executeUpdate(sql);53: stmt.close();54: }catch(SQLException e){55: }56: %>57: <html>Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:98) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435) org.apache.jasper.compiler.Compiler.compile(Compiler.java:298) org.apache.jasper.compiler.Compiler.compile(Compiler.java:277) org.apache.jasper.compiler.Compiler.compile(Compiler.java:265) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.
전체소스는 다음과 같습니다.
%@ page contentType="text/html;charse=euc-kr"%>
<%@ page language="java" import="java.sql.*,java.util.*,javax.servlet.http.*" %>
<%!
Connection DB_Connection()throws ClassNotFoundException,SQLException,Exception
{
String url="jdbc:mysql://localhost:8080/board";
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn=DriverManager.getConnection(url,"root","1234");
return conn;
}
String TO_DB(String str)thorws Exception
{
if(str==null)
{
return null;
}
return new String(str.getBytes("8859_1"),"KSC5601");
}
%>
<%!
Connection conn=DB_Connection();
Statement stmt=null;
String user_name=request.getParameter("user_name");
user_name=TO_DB(user_name);
String passwd=request.getParameter("passwd");
String type=request.getParameter("type");
String title=request.getParameter("title");
title=TO_DB(title);
String e_mail=request.getParameter("e_mail");
String home_url=request.getParameter("home_url");
String description=request.getParameter("description");
description=TO_DB(description);
try{
stmt=conn.createStatement();
String sql="insert into board(articleid, "+
"title,user_name,write_date,type,e_mail,home_url,"+
"hits,passwd,description)"+
"values(seq_board.nextval"+
",'"+title+
"','"+user_name+
"',sysdate"+
",'"+type+
"','"+e_mail+
"','"+home_url+
"',0"+
",'"+passwd+
"','"+description+"')";
stmt.executeUpdate(sql);
stmt.close();
}catch(SQLException e){
}
%>
<html>
<head>
<script language="javascript">
function alrim(){
alert("성공적으로 등록하였습니다.")
//location.href="list.jsp";
}
</script>
</head>
<body onload="alrim();">
</body>
</html>
원래 오라클db를 사용한 소스인데 mysql로 변경하려고 합니다.
톰캣에러는 다음과 같습니다.
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: Unable to compile class for JSP: JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 12 in the jsp file: /jsp_example/write.jspSyntax error on token "thorws", throws expected9: return conn;10: }11: 12: String TO_DB(String str)thorws Exception13: {14: if(str==null)15: {JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 10 in the jsp file: /jsp_example/write.jspSyntax error on token "}", delete this token7: Class.forName("org.gjt.mm.mysql.Driver").newInstance();8: Connection conn=DriverManager.getConnection(url,"root","1234");9: return conn;10: }11: 12: String TO_DB(String str)thorws Exception13: {JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 54 in the jsp file: /jsp_example/write.jspSyntax error, insert "}" to complete MethodBody51: "','"+description+"')";52: stmt.executeUpdate(sql);53: stmt.close();54: }catch(SQLException e){55: }56: %>57: <html>JSP FileName:/jsp_example/write.jspJava FileName:/C:/tomcat5_5/work/Catalina/localhost/_//org/apache/jsp/jsp_005fexample\write_jsp.javaAn error occurred at line: 54 in the jsp file: /jsp_example/write.jspSyntax error, insert "Finally" to complete TryStatement51: "','"+description+"')";52: stmt.executeUpdate(sql);53: stmt.close();54: }catch(SQLException e){55: }56: %>57: <html>Stacktrace: org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:98) org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330) org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:435) org.apache.jasper.compiler.Compiler.compile(Compiler.java:298) org.apache.jasper.compiler.Compiler.compile(Compiler.java:277) org.apache.jasper.compiler.Compiler.compile(Compiler.java:265) org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:564) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:302) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:329) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:265) javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.25 logs.
전체소스는 다음과 같습니다.
%@ page contentType="text/html;charse=euc-kr"%>
<%@ page language="java" import="java.sql.*,java.util.*,javax.servlet.http.*" %>
<%!
Connection DB_Connection()throws ClassNotFoundException,SQLException,Exception
{
String url="jdbc:mysql://localhost:8080/board";
Class.forName("org.gjt.mm.mysql.Driver").newInstance();
Connection conn=DriverManager.getConnection(url,"root","1234");
return conn;
}
String TO_DB(String str)thorws Exception
{
if(str==null)
{
return null;
}
return new String(str.getBytes("8859_1"),"KSC5601");
}
%>
<%!
Connection conn=DB_Connection();
Statement stmt=null;
String user_name=request.getParameter("user_name");
user_name=TO_DB(user_name);
String passwd=request.getParameter("passwd");
String type=request.getParameter("type");
String title=request.getParameter("title");
title=TO_DB(title);
String e_mail=request.getParameter("e_mail");
String home_url=request.getParameter("home_url");
String description=request.getParameter("description");
description=TO_DB(description);
try{
stmt=conn.createStatement();
String sql="insert into board(articleid, "+
"title,user_name,write_date,type,e_mail,home_url,"+
"hits,passwd,description)"+
"values(seq_board.nextval"+
",'"+title+
"','"+user_name+
"',sysdate"+
",'"+type+
"','"+e_mail+
"','"+home_url+
"',0"+
",'"+passwd+
"','"+description+"')";
stmt.executeUpdate(sql);
stmt.close();
}catch(SQLException e){
}
%>
<html>
<head>
<script language="javascript">
function alrim(){
alert("성공적으로 등록하였습니다.")
//location.href="list.jsp";
}
</script>
</head>
<body onload="alrim();">
</body>
</html>