<%@ page import = "java.util.*" %>
<%@ page import = "java.sql.*" %>
..
<%@ page import = "java.io.*" %>
<%@ page contentType="text/xml; charset=EUC-KR" %>
<%!
/*********** 공통함수 *************/
// ResultSet 값 가져오기, 단, "null"을 ""로
public String rsGet(ResultSet rs, String id) throws Exception
{
if( rs.getString(id) == null )
return "";
else
return rs.getString(id);
}
// 한글 조회조건 처리용 함수
public static String enToko(String s)
{
String result = "";
try {
result = new String(s.getBytes("ISO-8859-1"), "EUC-KR");
} catch(Exception e) {
System.out.println(e);
}
return result;
}
%>
<%
/******* JDBC Connection *******/
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=EDU","edu","edu");
stmt = conn.createStatement();
try {
/******* SQL 실행 *************/
..
String SQL;
.. SQL="select * from base_sawon where name like '" + enToko(name) + "%%'" ..
rs = stmt.executeQuery(SQL);
..
while(rs.next())
{
.. rsGet(rs, "name") ..
}
..
}
/********* Error처리 ************/
catch(SQLException e) {
.. e.getMessage() ..
}
%>
<%
/******** JDBC Close *******/
if ( stmt != null ) try { stmt.close(); } catch (Exception e) {}
if ( conn != null ) try { conn.close(); } catch (Exception e) {}
%>
..
<%@ page import = "java.util.*" %>
..
<%@ page import = "java.sql.*" %>
<%@ page import="java.io.*" %>
<%@ page contentType="text/xml; charset=EUC-KR" %>
..
<%
/******* JDBC Connection *******/
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=EDU","edu","edu");
stmt = conn.createStatement();
String SQL = "";
..
try {
..
SQL = "insert into base_sawon ( name, sabun, dept, jikgup, sex, ipsa_date, marry, email, smemo ) values ( " +
"'" + .. + "'," +
"'" + .. + "'," +
"'" + ..+ "'," +
"'" + .. + "'," +
"'" + .. + "'," +
"'" + .. + "'," +
"'" + .. + "'," +
"'" + .. + "'," +
"'" + .. + "' )";
/*
or
SQL = "update base_sawon set " +
"name = '" + .. + "'," +
"sabun = '" + .. + "'," +
"dept = '" + .. + "'," +
"jikgup = '" + .. + "'," +
"sex = '" + .. + "'," +
"ipsa_date = '" + .. + "'," +
"marry = '" + .. + "'," +
"email = '" + .. + "'," +
"smemo = '" + .. + "' " +
"where " +
"name = " + "'" + .. + "'";
or
SQL = "delete from base_sawon where " +
"name = " + "'" + .. + "'";
*/
..
stmt.executeUpdate(SQL);
..
}
catch ( SQLException e ) {
.. e.getMessage() ..
}
/******** JDBC Close ********/
if ( stmt != null ) try { stmt.close(); } catch (Exception e) {}
if ( conn != null ) try { conn.close(); } catch (Exception e) {}
%>
..