<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.sql.*,javax.sql.*, java.io.*"%>
<%!
// DB 설정
String url, id = "DB네임", passwd = "DB패스워드";
public void jspInit() {
try {
url = "jdbc:mysql://서버주소:포트/디비명";
String option="?
useUnicode=true&characterEncoding=UTF8";
url = url + option;
Class.forName("com.mysql.jdbc.Driver").newInstance();
} catch (Exception e) {
e.printStackTrace();
}
}
%>
<%
Connection conn=DriverManager.getConnection(url,id,passwd);
PreparedStatement ptmt =conn.prepareStatement("쿼리문");
ResultSet rs=ptmt.executeQuery();
%>
<%
while(rs.next())
{
}
ptmt.close();
conn.close();
%>