mis::/home1/htdocs/WEB-INF/classes#cat haksa_jdbc.java
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import javax.sql.*;
import elsoft.jdbc.*;
import javax.naming.*;
// ÁÖÀÇ hnwweblogic.java À̸§À» ´Ù¸¥À̸§.java ·Î º¯°æ»ç¿ë½Ã
// public class ´Ù¸¥À̸§ extends HttpServlet
public class haksa_jdbc extends javax.servlet.http.HttpServlet
{
//elsjdbc¸¦ »ý¼º ÇÕ´Ï´Ù.(Çʼö »çÇ×)
private elsjdbc m_HnwQuery = new elsjdbc();
static final String stParameter = "PoolName";
static final String DefaultPoolName = "oraclePool";
//static final String m_stDriverClass = "oracle.jdbc.driver.OracleDriver
";
//static final String m_stURL = "jdbc:oracle:thin:@192.168.1.16:1521:orc
l";
//static final String m_stUID = "elsoft";
//static final String m_stPWD = "hee";
static final int m_nMaxThreads = 70; //ÃÖ´ë µ¿½Ã Á¢¼Ó ¼ö¸¦ ÁöÁ¤ ÇÕ´Ï´Ù
.
static final int m_nTimeOut = 60; //ÃÖ´ë µ¿½Ã Á¢¼Ó ¼ö¸¦ ÃÊ°¡ ½Ã ´ë
±â½Ã°£(ÃÊ)
//Unicode¸¦ KSC5601·Î º¯È¯ÇÑ´Ù.
//ÀϺΠOS¿¡¼ Encoding ¹®ÀÚ "KSC5601"¸¦ »ç¿ë ÇÏ¿©¾ß ÇÑ´Ù.
public final static int IN_NONE = 0;
public final static int IN_ENG_TO_KOR = 1;
public final static int IN_KOR_TO_ENG = 2; //º¸Åë DB NLS°¡ ¿µ¹®À϶§
//
public final static int OUT_NONE = 0;
public final static int OUT_TO_KOR = 1;
public final static int OUT_ENG_TO_KOR = 2; //º¸Åë DB NLS°¡ ¿µ¹®À϶§
//
static final String m_stEncoding = "KSC5601";//Encoding ¹®ÀÚ(KSC5601,MS9
49,...)
static final int m_nInEncoding = 0; //Input String º¯È¯Çü½Ä.Çѱۺ¯È¯
ÀÌ ´Ù¸¦°æ¿ì À§ º¯¼ö·Î º¯°æÇϽÿÀ.
static final int m_nOutEncoding = 0; //Output Stringf º¯È¯ Çü½Ä.
static final boolean m_bTrim = false; //¹®ÀÚ Çʵå Trim »ç¿ë ¿©ºÎ.
//------------------------------------ÀÌ»ó EncodingÀ» À§ÇÑ ¸â¹ö
//Pool À̸§
String PoolName = null;
DataSource jdbcURL = null;
public void doPost(HttpServletRequest request, HttpServletResponse respo
nse)
throws ServletException, IOException
{
Connection conn = null;
try
{
InitialContext context = null;
context = new InitialContext();
jdbcURL = (DataSource) context.lookup("jdbc/OracleDS");
// Was¿¡¼ ÁÖ¾îÁø µðºñÇ®¿¡¼ Connection°´Ã¼¸¦ ¾ò´Â´Ù.
conn = jdbcURL.getConnection();
//elsjdbc¸¦ ÀÌ¿ëÇÏ¿© Äõ¸®¸¦ ½ÇÇàÇÔ
m_HnwQuery.RunQuery(request,response,conn);
}
catch(Exception ex)
{
String stError = "Can't Connection:";
stError += ex.getMessage();
//Ŭ¶óÀ̾ðÆ®¿¡ ¿À·ù ¸Þ½ÃÁö¸¦ Àü´ÞÇÑ´Ù.
m_HnwQuery.SendClientErrorMsg(request,response,stError);
}
finally {
// free statements and database connections
if ( conn !=null ) {
try {
conn.close();
}
catch (Exception e) {
System.out.println("Close connection exc
eption: " +
e.getMessage());
}
}
}
}
//¼ºí·¿ GET ¿äû ½Ã È£ÃâµÊ
//Connect Pooling¿¡ ´ëÇÑ ÇöÀç Á¤º¸¸¦ ¸ð´ÏÅ͸µÇÔ.
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
//elsjdbcÀÇ ÇöÀç Á¤º¸¸¦ º¸¿©ÁØ´Ù.
m_HnwQuery.getStatus(request,response);
}
//
//Servlet ÃʱâÈ ½Ã È£ÃâµÊ
//elsjdbcÀÇ Connect PoolingÀ» À§ÇÑ Çʼö ÇÔ¼ö ÀÔ´Ï´Ù.
//À¥¼¹ö ÀÚü Connect PoolingÀ» »ç¿ëÇÒ °æ¿ì ¾Æ·¡ ÇÔ¼ö¸¦ »èÁ¦ ÇϽʽÿÀ.
//------>
public void init(ServletConfig config) throws ServletException
{
super.init(config);
//Pool À̸§À» ÃʱâÈ ÆĶó¹ÌÅÍ·Î Àü´Þ¹Ý´Â´Ù.
//À¥·ÎÁ÷ ȯ°æ ¼³Á¤ ÆÄÀÏ¿¡ ¼³Á¤Çسí À̸§
PoolName = config.getInitParameter(stParameter);
if( PoolName == null ) PoolName = DefaultPoolName;
//¿ÃÁ¨¿¡¼ [JDBCSessionConnect],[JDBCSessionClose] À» »ç¿ëÇÒ°æ¿ì
¿¡ »ç¿ëµÈ´Ù.
//m_HnwQuery.init(m_stDriverClass,m_nMaxThreads,m_nTimeOut,m_stU
RL,m_stUID,m_stPWD);
//Encoding ¹®ÀÚ "KSC5601"¸¦ »ç¿ë ÇÏ¿©¾ß ÇÒ ¶§ ÁöÁ¤ÇÑ´Ù.
m_HnwQuery.UseEncoding(m_nInEncoding,m_nOutEncoding,m_stEncoding
,m_bTrim);
}
//Servlet Á¾·á ½Ã È£ÃâµÊ
//ConnectµÈ ¸ðµç Pooling¸¦ ´Ý½À´Ï´Ù.
//¿ÃÁ¨¿¡¼ [JDBCSessionConnect],[JDBCSessionClose] À» »ç¿ëÇÒ°æ¿ì¿¡ »ç¿ëµÈ´Ù.
public void destroy()
{
super.destroy();
m_HnwQuery.release();
}
}
mis::/home1/htdocs/WEB-INF/classes#
|