jsp초보개발자
12
2016-06-09 19:50:00
1
1191

초보 jsp mysql 연동해서 내용보기



my sql로 값을 호출한 것입니다.

-----------------------------------------------------------------------------------

그래서 이클립스에 아래와 같이 코드를 입력하였습니다.


코드부


<%@ page language="java" contentType="text/html; charset=EUC-KR"

    pageEncoding="EUC-KR"%>

    <%@ page import = "java.sql.DriverManager" %>

    <%@ page import = "java.sql.Connection" %>

    <%@ page import = "java.sql.Statement" %>

    <%@ page import = "java.sql.ResultSet" %>

    <%@ page import = "java.sql.SQLException" %>

<!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>회원목록</title>

</head>

<body>

MEMBER 테이블의 내용

<table width="100%" border="1">

<tr>

<td>이름</td><td>아이디</td><td>이메일</td>

</tr>

<%

// 1. jdbc 드라이버 로딩

Class.forName("com.mysql.jdbc.Driver");


Connection conn=null;

Statement stmt=null;

ResultSet rs=null;


try{

String jdbcDriver="jdbc:mysql://localhost:3306/chap11?" + "useUnicode=true&characterEncoding=euc-kr";

String dbUser="jspexam";

String dbPass="jspex";

String query="select * from chap11.member order by MEMBERID";

//2. 데이터 베이스 커넥션 생성

conn = DriverManager.getConnection(jdbcDriver, dbUser, dbPass);

//3. Statement 생성

stmt = conn.createStatement();

//4. 쿼리실행

rs = stmt.executeQuery(query);

while(rs.next()){

%>

<tr>

<td><%=rs.getString("NAME") %></td>

<td><%=rs.getString("MEMBERID") %></td>

<td><%=rs.getString("EMAIL") %></td>

</tr>

<%

}

}catch(SQLException ex){

// 에러발생

ex.printStackTrace();

}finally{

// 6.사용한  Statement 종료

if(rs !=null) try {rs.close();} catch(SQLException ex) {}

if(stmt !=null) try {rs.close();} catch(SQLException ex) {}

// 7.커넥션 종료

if(conn !=null) try {conn.close();} catch(SQLException ex) {}

}

%>

</table>

</body>

</html>

-----------------------------------------------------------------------

그랬더니, 기대와는 달리 아래와 같은 내용이 없는 결과가 나왔습니다. (이런제길.....) 

결과값



-----------------------------------------------------------------------

그래서 아래 콘솔부의 내용을 복사하여 아래와 같이 올립니다.


콘솔부


4월 10, 2016 8:53:27 오후 org.apache.tomcat.util.digester.SetPropertiesRule begin

경고: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:chap11' did not find a matching property.

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Server version:        Apache Tomcat/7.0.67

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Server built:          Dec 7 2015 13:07:11 UTC

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Server number:         7.0.67.0

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: OS Name:               Windows 7

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: OS Version:            6.1

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Architecture:          x86

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Java Home:             C:\Program Files\Java\jre1.8.0_77

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: JVM Version:           1.8.0_77-b03

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: JVM Vendor:            Oracle Corporation

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: CATALINA_BASE:         C:\apache-tomcat-7.0\webapps\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: CATALINA_HOME:         C:\Program Files\Apache Software Foundation\Tomcat 7.0

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Command line argument: -Dcatalina.base=C:\apache-tomcat-7.0\webapps\.metadata\.plugins\org.eclipse.wst.server.core\tmp0

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Command line argument: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 7.0

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Command line argument: -Dwtp.deploy=C:\apache-tomcat-7.0\webapps\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Command line argument: -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 7.0\endorsed

4월 10, 2016 8:53:27 오후 org.apache.catalina.startup.VersionLoggerListener log

정보: Command line argument: -Dfile.encoding=MS949

4월 10, 2016 8:53:27 오후 org.apache.catalina.core.AprLifecycleListener lifecycleEvent

정보: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre1.8.0_77\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:/Program Files/Java/jre1.8.0_77/bin/client;C:/Program Files/Java/jre1.8.0_77/bin;C:/Program Files/Java/jre1.8.0_77/lib/i386;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\;C:\Program Files\MySQL\MySQL Fabric 1.5 & MySQL Utilities 1.5\Doctrine extensions for PHP\;%JAVA_HOME%\bin;C:\Program Files\Java\jdk1.8.0_74\bin;;C:\eclipse;;.

4월 10, 2016 8:53:28 오후 org.apache.coyote.AbstractProtocol init

정보: Initializing ProtocolHandler ["http-bio-8080"]

4월 10, 2016 8:53:28 오후 org.apache.coyote.AbstractProtocol init

정보: Initializing ProtocolHandler ["ajp-bio-8009"]

4월 10, 2016 8:53:28 오후 org.apache.catalina.startup.Catalina load

정보: Initialization processed in 1959 ms

4월 10, 2016 8:53:28 오후 org.apache.catalina.core.StandardService startInternal

정보: Starting service Catalina

4월 10, 2016 8:53:28 오후 org.apache.catalina.core.StandardEngine startInternal

정보: Starting Servlet Engine: Apache Tomcat/7.0.67

4월 10, 2016 8:53:28 오후 org.apache.catalina.startup.TldConfig execute

정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

4월 10, 2016 8:53:29 오후 org.apache.catalina.util.SessionIdGeneratorBase createSecureRandom

정보: Creation of SecureRandom instance for session ID generation using [SHA1PRNG] took [187] milliseconds.

4월 10, 2016 8:53:29 오후 org.apache.catalina.startup.TldConfig execute

정보: At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.

4월 10, 2016 8:53:29 오후 org.apache.coyote.AbstractProtocol start

정보: Starting ProtocolHandler ["http-bio-8080"]

4월 10, 2016 8:53:29 오후 org.apache.coyote.AbstractProtocol start

정보: Starting ProtocolHandler ["ajp-bio-8009"]

4월 10, 2016 8:53:29 오후 org.apache.catalina.startup.Catalina start

정보: Server startup in 1342 ms

com.mysql.jdbc.exceptions.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '&"*?&&&"!?)%&' at line 1

at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:936)

at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2985)

at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1631)

at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1723)

at com.mysql.jdbc.Connection.execSQL(Connection.java:3277)

at com.mysql.jdbc.Connection.execSQL(Connection.java:3206)

at com.mysql.jdbc.Statement.executeQuery(Statement.java:1232)

at com.mysql.jdbc.Connection.loadServerVariables(Connection.java:4478)

at com.mysql.jdbc.Connection.initializePropsFromServer(Connection.java:4062)

at com.mysql.jdbc.Connection.createNewIO(Connection.java:2789)

at com.mysql.jdbc.Connection.<init>(Connection.java:1555)

at com.mysql.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:285)

at java.sql.DriverManager.getConnection(Unknown Source)

at java.sql.DriverManager.getConnection(Unknown Source)

at org.apache.jsp.viewMemberList_jsp._jspService(viewMemberList_jsp.java:121)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:439)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:395)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:339)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:731)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:303)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:208)

at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:220)

at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:122)

at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:505)

at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:169)

at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)

at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:956)

at org.apache.catalina.core.StandardEngineVal‎ve.invoke(StandardEngineVal‎ve.java:116)

at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:423)

at org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1079)

at org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:625)

at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:316)

at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)

at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)

at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)

at java.lang.Thread.run(Unknown Source)

-----------------------------------------------------------------------

도대체 무엇이 잘못되어 결과값이 나오지 않는지 너무 많이 우울합니다.

선생님들께서 미천한 중생에게 가르쳐 주세요 부탁합니다.


0
  • 답변 1

  • jsp초보개발자
    12
    2016-06-15 22:28:55

    자체 해결 하였습니다. web-inf > lib 폴더에 커넥션 파일을 복사하지 않은 것이 문제였습니다.

  • 로그인을 하시면 답변을 등록할 수 있습니다.