database.sarang.net
UserID
Passwd
Database
DBMS
MySQL
PostgreSQL
Firebird
Oracle
Informix
Sybase
MS-SQL
DB2
Cache
ㆍCUBRID
LDAP
ALTIBASE
Tibero
DB 문서들
스터디
Community
공지사항
자유게시판
구인|구직
DSN 갤러리
도움주신분들
Admin
운영게시판
최근게시물
CUBRID Q&A 607 게시물 읽기
No. 607
Q.Tomcat Connection Pool 질문드립니다.
작성자
qwer
작성일
2007-10-11 14:58
조회수
4,349

안녕하세요

 

톰캣에서 큐브리드 사용하기란 문서 보면서

하고 있는데 잘 안되서 질문드립니다.

 

현재 Tomcat 6.0.14 에서 jdbc를 이용하여 테스트 해보려고 하는데

에러가 납니다.

물론 제가 잘모르구요ㅜㅜ 잘못한게 있는거 같은데 못찾겠는데

조금만 도와주시면 안될까요..ㅜㅜ

 

그리고

tomcat6.0.14버젼에서 커넥션 풀을 이용한 방법 셋팅법은 바뀌지 않았는지요?

 

view.jsp

 

<%@ page contentType=\"text/html; charset=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.SQLException\" %>

 

<table>

  <tr>

    <td>이름</td>

    <td>아이디</td>

    <td>이메일</td>

  </tr>

  <%

  Class.forName(\"cubrid.jdbc.driver.CUBRIDDriver\");

  Connection Conn = null;

  Statement stmt = null;

  ResultSet rs = null;

  

  try

  {

      String jdbcDrv = \"jdbc:CUBRID:localhost:33000:demodb:::\";

      String dbUsr = \"kdnmih\";

      String dbPw = \"qwer\";

 

      conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

      stmt = conn.createStatement();

 

      query = \"select * from bed_and_breakfast\";

      rs   = stmt.executeQuery(query);

 

      while (rs.next())

      {

  %>

  <tr>

    <td>country</td>

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

    <td>cost</td>

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

  </tr>

  <tr>

    <td>rating</td>

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

    <td>owner</td>

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

  </tr>

  <%

      }

  }

  catch (SQLException ex)

  {

      // 에러발생

  }

  finally

  {

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

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

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

  }

 

  %>

  <tr>

    <td></td>

  </tr>

</table>

 

------------------------------ 에러내용------------------------------------

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:

 

An error occurred at line: 10 in the generated java file

Only a type can be imported. java.SQLException resolves to a package

 

An error occurred at line: 27 in the jsp file: /view_bed.jsp

conn cannot be resolved

24:       String dbUsr = \"kdnmih\";

25:       String dbPw = \"qwer\";

26:

27:       conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

28:       stmt = conn.createStatement();

29:

30:       query = \"select * from bed_and_breakfast\";

 

 

An error occurred at line: 28 in the jsp file: /view_bed.jsp

conn cannot be resolved

25:       String dbPw = \"qwer\";

26:

27:       conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

28:       stmt = conn.createStatement();

29:

30:       query = \"select * from bed_and_breakfast\";

31:       rs   = stmt.executeQuery(query);

 

 

An error occurred at line: 30 in the jsp file: /view_bed.jsp

query cannot be resolved

27:       conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

28:       stmt = conn.createStatement();

29:

30:       query = \"select * from bed_and_breakfast\";

31:       rs   = stmt.executeQuery(query);

32:

33:       while (rs.next())

 

 

An error occurred at line: 31 in the jsp file: /view_bed.jsp

query cannot be resolved

28:       stmt = conn.createStatement();

29:

30:       query = \"select * from bed_and_breakfast\";

31:       rs   = stmt.executeQuery(query);

32:

33:       while (rs.next())

34:       {

 

 

An error occurred at line: 51 in the jsp file: /view_bed.jsp

SQLException cannot be resolved to a type

48:   <%

49:       }

50:   }

51:   catch (SQLException ex)

52:   {

53:       // 에러발생

54:   }

 

 

An error occurred at line: 57 in the jsp file: /view_bed.jsp

SQLException cannot be resolved to a type

54:   }

55:   finally

56:   {

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

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

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

60:   }

 

 

An error occurred at line: 58 in the jsp file: /view_bed.jsp

SQLException cannot be resolved to a type

55:   finally

56:   {

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

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

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

60:   }

61:

 

 

An error occurred at line: 59 in the jsp file: /view_bed.jsp

conn cannot be resolved

56:   {

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

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

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

60:   }

61:

62:   %>

 

 

An error occurred at line: 59 in the jsp file: /view_bed.jsp

conn cannot be resolved

56:   {

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

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

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

60:   }

61:

62:   %>

 

 

An error occurred at line: 59 in the jsp file: /view_bed.jsp

SQLException cannot be resolved to a type

56:   {

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

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

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

60:   }

61:

62:   %>

 

 

Stacktrace:

        org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)

        org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)

        org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)

        org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)

        org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)

        org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)

        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)

        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)

        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

 

 

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

 

 

이 글에 대한 댓글이 총 1건 있습니다.

각 오류 내용별로 보면

1. conn cannot be resolved 는 Connection Conn = null;와 같이 정의하셨는데 실제 connection하는 부분에서는 conn을 사용하셔서 발생하였습니다.

Connection conn=null;과 같이 수정하시면 해결됩니다.

 

2. query cannot be resolved 는 query 변수가 정의되어 있지 않아서 발생하였습니다.

String query  = \"select * from bed_and_breakfast\";과 같이 수정하세요.

 

3. SQLException cannot be resolved to a type는 SQLException을 import하실때 packege명을 잘못주셔서 발생하였습니다.

<%@ page import = \"java.SQLException\" %>을 <%@ page import = \"java.sql.SQLException\" %>과 같이 수정하시면 해결됩니다.

 

참고로 질문에 올리신 소스를 보니 이것은 Tomcat의 Connection Pool(DBCP)을 사용하는 것이 아니라 DriverManager 방식을 사용하고 있네요.

DBCP 사용법은 아마 참고하시는 문서는 tomcat 5.0버전을 기준으로 작성된 것이라 5.5이상 사용하시는 분들은 에러가 발생할 것입니다. 해결방법은 FAQ&TIP tomcat 5.5 버전 이상에서 dbcp(커넥션 풀링) 설정법을 참고하시기 바랍니다.

FAQ를 보시면 아시겠지만 Tomcat 5.5 부터는 sever.xml의 Resource 태그 사용시 Resource파라미터를 따로 분리하지 않고 하나로 사용하면서 기존방식을 지원하지 않아서 에러가 발생합니다.

 

>안녕하세요

>

>톰캣에서 큐브리드 사용하기란 문서 보면서

>하고 있는데 잘 안되서 질문드립니다.

>

>현재 jdk1.6 + Tomcat 6.0.14 에서 jdbc를 이용하여 테스트 해보려고 하는데

>에러가 납니다.

>물론 제가 잘모르구요ㅜㅜ 잘못한게 있는거 같은데 못찾겠는데

>조금만 도와주시면 안될까요..ㅜㅜ

>

>그리고

>tomcat6.0.14버젼에서 커넥션 풀을 이용한 방법 셋팅법은 바뀌지 않았는지요?

>

>view.jsp

>

><%@ page contentType=\"text/html; charset=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.SQLException\" %>

>

><table>

>  <tr>

>    <td>이름</td>

>    <td>아이디</td>

>    <td>이메일</td>

>  </tr>

>  <%

>  Class.forName(\"cubrid.jdbc.driver.CUBRIDDriver\");

>  Connection Conn = null;

>  Statement stmt = null;

>  ResultSet rs = null;

>  

>  try

>  {

>      String jdbcDrv = \"jdbc:CUBRID:localhost:33000:demodb:::\";

>      String dbUsr = \"kdnmih\";

>      String dbPw = \"qwer\";

>

>      conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

>      stmt = conn.createStatement();

>

>      query = \"select * from bed_and_breakfast\";

>      rs   = stmt.executeQuery(query);

>

>      while (rs.next())

>      {

>  %>

>  <tr>

>    <td>country</td>

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

>    <td>cost</td>

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

>  </tr>

>  <tr>

>    <td>rating</td>

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

>    <td>owner</td>

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

>  </tr>

>  <%

>      }

>  }

>  catch (SQLException ex)

>  {

>      // 에러발생

>  }

>  finally

>  {

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

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

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

>  }

>

>  %>

>  <tr>

>    <td></td>

>  </tr>

></table>

>

>------------------------------ 에러내용------------------------------------

>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:

>

>An error occurred at line: 10 in the generated java file

>Only a type can be imported. java.SQLException resolves to a package

>

>An error occurred at line: 27 in the jsp file: /view_bed.jsp

>conn cannot be resolved

>24:       String dbUsr = \"kdnmih\";

>25:       String dbPw = \"qwer\";

>26:

>27:       conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

>28:       stmt = conn.createStatement();

>29:

>30:       query = \"select * from bed_and_breakfast\";

>

>

>An error occurred at line: 28 in the jsp file: /view_bed.jsp

>conn cannot be resolved

>25:       String dbPw = \"qwer\";

>26:

>27:       conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

>28:       stmt = conn.createStatement();

>29:

>30:       query = \"select * from bed_and_breakfast\";

>31:       rs   = stmt.executeQuery(query);

>

>

>An error occurred at line: 30 in the jsp file: /view_bed.jsp

>query cannot be resolved

>27:       conn = DriverManager.getConnection(jdbcDrv, dbUsr, dbPw);

>28:       stmt = conn.createStatement();

>29:

>30:       query = \"select * from bed_and_breakfast\";

>31:       rs   = stmt.executeQuery(query);

>32:

>33:       while (rs.next())

>

>

>An error occurred at line: 31 in the jsp file: /view_bed.jsp

>query cannot be resolved

>28:       stmt = conn.createStatement();

>29:

>30:       query = \"select * from bed_and_breakfast\";

>31:       rs   = stmt.executeQuery(query);

>32:

>33:       while (rs.next())

>34:       {

>

>

>An error occurred at line: 51 in the jsp file: /view_bed.jsp

>SQLException cannot be resolved to a type

>48:   <%

>49:       }

>50:   }

>51:   catch (SQLException ex)

>52:   {

>53:       // 에러발생

>54:   }

>

>

>An error occurred at line: 57 in the jsp file: /view_bed.jsp

>SQLException cannot be resolved to a type

>54:   }

>55:   finally

>56:   {

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

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

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

>60:   }

>

>

>An error occurred at line: 58 in the jsp file: /view_bed.jsp

>SQLException cannot be resolved to a type

>55:   finally

>56:   {

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

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

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

>60:   }

>61:

>

>

>An error occurred at line: 59 in the jsp file: /view_bed.jsp

>conn cannot be resolved

>56:   {

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

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

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

>60:   }

>61:

>62:   %>

>

>

>An error occurred at line: 59 in the jsp file: /view_bed.jsp

>conn cannot be resolved

>56:   {

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

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

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

>60:   }

>61:

>62:   %>

>

>

>An error occurred at line: 59 in the jsp file: /view_bed.jsp

>SQLException cannot be resolved to a type

>56:   {

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

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

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

>60:   }

>61:

>62:   %>

>

>

>Stacktrace:

>        org.apache.jasper.compiler.DefaultErrorHandler.javacError(DefaultErrorHandler.java:92)

>        org.apache.jasper.compiler.ErrorDispatcher.javacError(ErrorDispatcher.java:330)

>        org.apache.jasper.compiler.JDTCompiler.generateClass(JDTCompiler.java:423)

>        org.apache.jasper.compiler.Compiler.compile(Compiler.java:308)

>        org.apache.jasper.compiler.Compiler.compile(Compiler.java:286)

>        org.apache.jasper.compiler.Compiler.compile(Compiler.java:273)

>        org.apache.jasper.JspCompilationContext.compile(JspCompilationContext.java:566)

>        org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:317)

>        org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)

>        org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)

>        javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

>

>

>note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.

손승일님이 2007-10-11 15:43에 작성한 댓글입니다. Edit
[Top]
No.
제목
작성자
작성일
조회
610Q.Tomcat에서 CUBRID 사용하기 문서관련 질문 [1]
qwer
2007-10-12
5722
609Q.mysql과 cubrid를 같은 서버에서 같이 동작시킬수도 있나요?? [2]
황현태
2007-10-12
3390
608Q.OLE방식을 사용하고 있습니다... [3]
다트25
2007-10-12
3631
607Q.Tomcat Connection Pool 질문드립니다. [1]
qwer
2007-10-11
4349
606Q.팝업 메뉴를 이용한 레코드 삭제 문의 [1]
궁금이
2007-10-11
3417
605Q.큐브리드 jdbc 드라이버를 받고싶습니다.
안성민
2007-10-10
3337
604Q.쿼리로 계산가능한지......
큐브리드맨
2007-10-09
3365
Valid XHTML 1.0!
All about the DATABASE... Copyleft 1999-2024 DSN, All rights reserved.
작업시간: 0.017초, 이곳 서비스는
	PostgreSQL v16.2로 자료를 관리합니다