톰캣의 jndi 로 등록한 db가 접속이 안되네요.

aNsITAte의 이미지

설치된 환경은 다음과 같습니다.
데비안

apache2 + jdk1.5.0_4 + tomcat 5.5.9 + mysql 4.0 + mysql connector/j 3.1 (jdbc driver)

connector/j 는 현재 tomcat/common/lib 에 jar 파일만 하나 등록한 상태입니다.

server.xml 에 추가한 내용

Quote:
<GlobalNamingResources>
.
.
<Resource
name="jdbc/zeropage"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
password="PASSWORD"
maxIdle="2"
maxWait="5000"
username="USER"
url="jdbc:mysql://127.0.0.1:3306/zeropage?useUnicode=true&amp;characterEncoding=KSC5601"
maxActive="4"/>
.
.
</GlobalNamingResources>

실행한 소스의 내용

Quote:
<%@ page import="java.sql.*, javax.naming.*, javax.sql.*"%>
<%
Context initCtx = new InitialContext();
Context envCtx = (Context) initCtx.lookup("java:comp/env");
DataSource ds = (DataSource) envCtx.lookup("jdbc/zeropage");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
String query = "select now()";
ResultSet rs = stmt.executeQuery(query);
if(rs.next()) {
out.println(rs.getTimestamp(1));
}
rs.close();
stmt.close();
conn.close();
%>

결과 에러메시지

Quote:
exception

javax.servlet.ServletException: Cannot create JDBC driver of class '' for connect URL 'null'
org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848)
org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781)
org.apache.jsp.mysql_jsp._jspService(org.apache.jsp.mysql_jsp:78)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

root cause

org.apache.tomcat.dbcp.dbcp.SQLNestedException: Cannot create JDBC driver of class '' for connect URL 'null'
org.apache.tomcat.dbcp.dbcp.BasicDataSource.createDataSource(BasicDataSource.java:780)
org.apache.tomcat.dbcp.dbcp.BasicDataSource.getConnection(BasicDataSource.java:540)
org.apache.jsp.mysql_jsp._jspService(org.apache.jsp.mysql_jsp:54)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

확인해보면 대충 jdbc/zeropage 라는 것의 내용을 가져오지 못하고 있는 것 같습니다. 혹시 jndi를 쓰기위해서 tomcat 에 더 설치해야할 파일이 있는 건가요?

이상하네요.

http://www.zeropage.org/mysql.jsp

제가 설정을 한 과정에서 무언가 빠진 내용이 잇는지고 궁금하고, 톰캣으로 jndi 를 쓰고 계신분들 어떻게 설정하고 계신지 궁금합니다.

herblover의 이미지

에궁.. jakarta-korea 팀이 지금 리뉴얼(??) 작업중이라 번역 문서들이 안올라가 있네요. 조만간 수정하도록 하겠습니다.
Kenu 님이 viewlet으로 만들어 놓으신 강좌가 도움이 될지도 모르겠네요.

http://www.okjsp.pe.kr/bbs?act=VIEW&seq=54309&bbs=lecture&keyfield=content&keyword=&pg=0

관련자료는, google신께 "dbcp 설정" 으로 신탁을 요청해 보시면.. @.@

herblover의 이미지

아차, tomcat 5.5 라면, 톰캣 다운로드 사이트에서 위의 tomcat admin 프로그램을 별도로 받아서 설치해 주셔야 합니다.

aNsITAte의 이미지

무슨 이유인지는 모르겠지만..

글로벌로 지정하면 안되고.. context.xml 파일을 수정해서

접속하는 것이 가능했습니다.

그립다는 것은 아직도 네가 내 안에 남아 있다는 뜻이다.
그립다는 것은 지금은 너를 볼 수 없다는 뜻이다.
볼 수는 없지만 보이지 않는 내 안 어느 곳에 네가 남아 있다는 뜻이다.
-이정하의 《혼자 사랑한다는 것은》중에서-

kwon37xi의 이미지

Global로 지정할 경우에는 각 컨텍스트 설정에서도 글로벌로 지정된 리소스를 사용할 수 있도록 하는 설정이 더 필요합니다.

아니면 아예 컨텍스트에 지정을 해버리던지요.

http://kr.blog.yahoo.com/kwon37xi/1236540.html?p=1&pm=l&sk=0&sv=JNDI

저기를 참조해보시기 바랍니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.