iisweb


º¸¾ÈÁ¢¼Ó
 
ID

PW

 
 

°øÁö»çÇ×

 

1:1 °í°´»ó´ã

 

ÀÚÁÖ¹¯´ÂÁú¹®

 

ÁÖ¿ä ¸Þ´º¾ó

 

ÆÁ & ³ëÇÏ¿ì

 

¿­¸° IT Á¤º¸½Ç

 

HOME > °í°´¼¾ÅÍ > ÀÚÁÖ¹¯´Â Áú¹®

Áú¹® JNDI¸¦ ÀÌ¿ëÇÑ mysql ¿¬°á ¿¹Á¦(´Üµ¶ÅèĹ)
ºÐ·ù JSPÈ£½ºÆÃ
¾È³çÇϼ¼¿ä.
¾ÆÀÌÁîÀ¥ È£½ºÆà ÀÔ´Ï´Ù.
 
[server.xml]
server.xml¿¡¼­ ±âÁ¸ Context ¼³Á¤À» ´ÙÀ½°ú °°ÀÌ º¯°æÇÕ´Ï´Ù.

<Context path="" docBase="www">
<Resource name="jdbc/mytc5"
auth="Container"
type="javax.sql.DataSource"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/dbname"
username="dbuser"
password="dbpasswd"
maxActive="20"
maxIdle="10"
maxWait="3000"/>
</Context>

[web.xml]
<resource-ref>
<res-ref-name>jdbc/mytc5</res-ref-name>
<res-type>javax.sql.DataSource</res-type>
<res-auth>Container</res-auth>
</resource-ref>

[jdbctest.jsp]
<html>
<head>
<%@ page errorPage="errorpg.jsp"
import="java.sql.*,
javax.sql.*,
java.io.*,
javax.naming.InitialContext,
javax.naming.Context" %>
</head>
<body>
<h1>JDBC JNDI Resource Test</h1>

<%
InitialContext initCtx = new InitialContext();
DataSource ds = (DataSource) initCtx.lookup("java:comp/env/jdbc/mytc5");
Connection conn = ds.getConnection();
Statement stmt = conn.createStatement();
ResultSet rset = stmt.executeQuery("select version();");
while (rset.next()) {
out.println("mysql version=="+rset.getString("version()"));
}
rset.close();
stmt.close();
conn.close();
initCtx.close();
%>
</body>
</html>
 
°¨»çÇÕ´Ï´Ù.
 
 
 
¾ÆÀÌÁîÀ¥

»óÈ£ : ¿Ã¸®ºêÀÎÅÍ³Ý | ´ëÇ¥ : ¼ÕÁß¿¬ | ¼ÒÀçÁö : ´ëÀü±¤¿ª½Ã µ¿±¸ Áß¾Ó·Î 200¹ø±æ 40, 2Ãþ (¿øµ¿, ÀÚÀ¯µµ¸Å½ÃÀå)

»ç¾÷ÀÚµî·Ï¹øÈ£ : 314-14-89838 [»ç¾÷ÀÚÁ¤º¸È®ÀÎ] | Åë½ÅÆǸž÷½Å°í¹øÈ£ : Á¦2011-´ëÀü¼­±¸-0120È£

ÀüÈ­¹øÈ£ : 1644-7011(ÇØ¿Ü 070-7174-2067) | Æѽº¹øÈ£ : 050-5270-7769 | °³ÀÎÁ¤º¸ º¸È£Ã¥ÀÓÀÚ : ¼ÕÁß¿¬ | È£½ºÆà Á¦°ø : ¿Ã¸®ºêÀÎÅͳÝ

°í°´¼¾ÅÍ À̸ÞÀÏ : | ºñȸ¿ø ¹®ÀÇÇϱâ

Copyright © Oliveinternet Inc. All Rights Reserved.