PC

블로그 이미지

DAVID

160407: 19회차

Programming 2016. 4. 7. 12:31

종료하기 전 티스토리 네이버 로그아웃 할 것


1. 툴

동일

추가시: 


2. 폴더

동일

추가시:


3. 사용할 사이트

동일

추가시:


4. 공부하는 것


오늘 인터넷이 짱 느려서 걱정스럽지만 ㄱㄱ


오늘도 씨퀀스를 쓰는군

 넥스트발... **...


세로드립이 아닙니다

그냥 볼드를 주고 싶어서 준 것


createForm.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

    <% request.setCharacterEncoding("utf-8"); %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<style>

*{

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<DIV style="text-align: center; margin-top: 20px; margin-bottom: 20px;"> 등록 </DIV>

<form name="frm" method="POST" action="./createProc.jsp">

<table width="50%" align="center" border="1">

<tr>

<th>제목</th>

<td><input type = 'text' name = 'title' size = '30' value = '화요일'></td>

</tr>

<tr>

<th>내용</th>

<td><textarea name = 'content' rows = '10' cols = '30'>SQL 수업 </textarea></td>

</tr>

</table>

<div style="text-align: center; margin-top: 20px; margin-bottom: 20px;"><input type = "submit" value="전송"></div>

</form>


</body>

</html>


요기서 뽀인트는 value = '값값' 써주면 입력한 밸류값이 디폴트로 텍스트창에 출력됩니다

얘는 플레이스홀더 같은 게 아니라 이거 지우고 써줘야함미다


그러니까 사용자 편의를 위해서라면 입력할 때는 플레이스홀더를 씁시다.


---------------------------------------------------------


여기서 잠시 킵


createProc.jsp


<%@page import="java.sql.PreparedStatement"%>

<%@page import="java.sql.Connection"%>

<%@page import="java.sql.DriverManager"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<% request.setCharacterEncoding("UTF-8"); 

String title = request.getParameter("title");

String content = request.getParameter("content");


String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";

String id = "soldesk";

String pass = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

/*forName이 뭐냐?★ - ㅋㅋㅋㅋㅋ 복습하기.. 드라이버 올리는 역할을 하는거라는뎅*/

//class.forname = 메모리에 올리는것 :> 이래.. 내가썼네

// 드라이버명을 명시하려고 쓰는 것 

// 얘를 1차적으로 해줘야 애들이 뭐로 무엇을 어디에 넣냐고! 이런 소리 안함

// 야! 500워닝 소리 안들리게 해라! 같은 것 - 몇번인진 모르는데 그냥 500이 땡겨서


// 어쨌든 이 클래스를 찾아서 메모리에 올리는 행위 입니다

//근뎅 이 프로젝트가 웹 다이나믹 프로젝트라서

// 저렇게 해줘야 된대영 실행하려면 -.-)



Connection con = DriverManager.getConnection(url, id, pass);

PreparedStatement pstmt = null;

//위에 애들 임뽀트를 넘나 편하게 했습니다 이클립스만세!


String sql = null;

int cnt = 0; //실행했을 때 필요한 변수를 선언해놓음


sql = "INSERT INTO memo(memono, title, content, wdate) "; //요기 한칸 띄워줘야 됨...

sql += "VALUES(memo_seq.nextval, ?, ?, sysdate)";

// insert into 아니면 values 같이 소문자로 써도 됨

// 근데 파라메타 아니면 대문자로 쓰는게 보기가 좋자나...

//이뻐야합니다 (필수)

// 난 왜이렇게 시퀀스가 싫읋까

// 시퀀스를 주깁시다 우리의 원수

// 씨퀀쑤!!!!!!!!! ㅆㄲㅆ! 

// 그의 친구 넥스트발도 주깁시다!

// 킬! 터미네이트!


//어근뎅 쓰트링인데도 막 추가해서 넣네 -.-);;;;;


pstmt = con.prepareStatement(sql);

pstmt.setString(1, title);

pstmt.setString(2, content);

//이거 나온 부분 복습하귀... 엑쓰큐트 업데이트가 희미한 기억이다

// 이런 걸 하는 패턴은 기억나는데 메소드명이 기억안나 OTL...


cnt = pstmt.executeUpdate();


%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>

뿌록

</body>

</html>


<!-- 

String url = "jdbc:oracle:thin:127.0.0.1:1521:XE";

아니면

String url = "jdbc:oracle:thin:@localhost:1521:XE";

로 쓰면 됩니다

 -->





쉬는 시간인데 계속 한다!

열정강의!


그리고 발 저리다!



http://aroundck.tistory.com/11


이거 String + 로 만들 때 문제점 쓴건뎅


+ 로 연결하여 assign 하게 된다면 + 하는 String 의 갯수가 늘어나면 늘어날수록
GC 대상 object 수도 함께 늘어나고 그만큼 memory 할당도 추가로
 늘어나게 된다는 것입니다.


하지만 이 문제는 query 문을 만드는데서 많이 발생합니다.
Query Operation은 매우 무거운 작업입니다.
복잡한 Database 를 쓰는 경우, 여러번의 query 를 통해 결과를 도출하는 것은 엄청난 시간을 소비하기도 합니다.
따라서 가능한 query 횟수를 최소화 하여 원하는 결과를 뽑아내는 작업이 필요하며 이 과정에서
String + operation이 엄청나게 발생하곤 합니다.

따라서 메모리의 소모량이 엄청나게 되어 버리는 것이죠.



----------------------


쁘록은 파워복붙


<%@page import="java.sql.PreparedStatement"%>

<%@page import="java.sql.Connection"%>

<%@page import="java.sql.DriverManager"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<%

request.setCharacterEncoding("UTF-8");


String title = request.getParameter("title");

String content = request.getParameter("content");


String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";

String id = "soldesk";

String pass = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

/*forName이 뭐냐?★ - ㅋㅋㅋㅋㅋ 복습하기.. 드라이버 올리는 역할을 하는거라는뎅*/

//class.forname = 메모리에 올리는것 :> 이래.. 내가썼네

// 드라이버명을 명시하려고 쓰는 것 

// 얘를 1차적으로 해줘야 애들이 뭐로 무엇을 어디에 넣냐고! 이런 소리 안함

// 야! 500워닝 소리 안들리게 해라! 같은 것 - 몇번인진 모르는데 그냥 500이 땡겨서


// 어쨌든 이 클래스를 찾아서 메모리에 올리는 행위 입니다

//근뎅 이 프로젝트가 웹 다이나믹 프로젝트라서

// 저렇게 해줘야 된대영 실행하려면 -.-)


Connection con = DriverManager.getConnection(url, id, pass);

PreparedStatement pstmt = null;

//위에 애들 임뽀트를 넘나 편하게 했습니다 이클립스만세!


String sql = null;

int cnt = 0; //실행했을 때 필요한 변수를 선언해놓음


sql = "INSERT INTO memo(memono, title, content, wdate) "; //요기 한칸 띄워줘야 됨...

sql += "VALUES(memo_seq.nextval, ?, ?, sysdate)";

// insert into 아니면 values 같이 소문자로 써도 됨

// 근데 파라메타 아니면 대문자로 쓰는게 보기가 좋자나...

//이뻐야합니다 (필수)

// 난 왜이렇게 시퀀스가 싫읋까

// 시퀀스를 주깁시다 우리의 원수

// 씨퀀쑤!!!!!!!!! ㅆㄲㅆ! 

// 그의 친구 넥스트발도 주깁시다!

// 킬! 터미네이트!


//어근뎅 쓰트링인데도 막 추가해서 넣네 -.-);;;;;


pstmt = con.prepareStatement(sql);

pstmt.setString(1, title);

pstmt.setString(2, content);

//이거 나온 부분 복습하귀... 엑쓰큐트 업데이트가 희미한 기억이다

// 이런 걸 하는 패턴은 기억나는데 메소드명이 기억안나 OTL...


cnt = pstmt.executeUpdate();

%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<style type="text/css">

* {

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<DIV style='font-size: 24px; text-align: center; margin-top: 100px;'>

<%

if (cnt == 1) {

out.println("메모를 등록 했습니다.");

} else {

out.println("메모 등록에 실패했습니다.");

}

%>

<br> <input type='button' value='계속 등록'

onclick="location.href='./createForm.jsp'"> <input

type='button' value='목록' onclick="location.href='./list.jsp'">

</DIV>


</body>

</html>


<%

try {

if (pstmt != null) {

pstmt.close();


}

} catch (Exception e) {


}


try {

if (con != null) {

con.close();

}

} catch (Exception e) {


}

%>

<!-- 

String url = "jdbc:oracle:thin:127.0.0.1:1521:XE";

아니면

String url = "jdbc:oracle:thin:@localhost:1521:XE";

로 쓰면 됩니다

 -->



얘의 친구 table.jsp도 파워복붙


<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%><% request.setCharacterEncoding("utf-8"); %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<style type="text/css">

* {

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<DIV style='text-align: center;'>테이블 실습</DIV>

<TABLE align='center' border='1' cellpadding="10px" cellspacing="0px">

★ 쎌 패딩하고 쎌 쓰패이싱 ...

보더값 조절하고 어쩌구 저쩌구 임

물론 이따 찾아볼 것... -_-);;


뜻을 보면 셀 스페이싱 - 셀 과 셀 간의 간격

셀 패딩 - 컨텐츠와 셀 간의 간격



<TR>

<TH>번호</TH>

<TH>제목</TH>

<TH>내용</TH>

</TR>

<TR>

<TD align='center'>1</TD>

<TD align='center'>월요일</TD>

<TD>첫눈</TD>

</TR>

<TR>

<TD align='center'>2</TD>

<TD align='center'>화요일</TD>

<TD>메모장 제작</TD>

</TR>

<TR>

<TD align='center'>3</TD>

<TD align='center'>수요일</TD>

<TD>메모장 테스트</TD>

</TR>

</TABLE>


</body>

</html>


-----------------------------------------

테이블2 도 파워복붙

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<% request.setCharacterEncoding("utf-8"); %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title></title>
<style type="text/css">
* {
font-family: gulim;
font-size: 24px;
}
</style>
</head>
<body>
<TABLE align='center' border="1" cellpadding="20px" cellspacing="0px">
<TR>
<TH>1</TH>
<TH>2</TH>
<TH>3</TH>
<TH>4</TH>
<TH>5</TH>
</TR>
<TR>
<TH colspan='2' bgcolor="#FFFF00" align='center'>1 2</TH> - 첫번째 + 두번째
<TH>3</TH>
<TH>4</TH>
<TH>5</TH>
</TR>
<TR>
<TH>1</TH>
<TH colspan='2' bgcolor="#FFFF00" align='center'>2 3</TH> - 두번째 + 세번쨰
<TH>4</TH>
<TH>5</TH>
</TR>
<TR>
<TH>1</TH>
<TH>2</TH>
<TH colspan='2' bgcolor="#FFFF00" align='center'>3 4</TH> - 세번째 + 네번째
<TH>5</TH>
</TR>
<TR>
<TH>1</TH>
<TH>2</TH>
<TH>3</TH>
<TH colspan='2' bgcolor="#FFFF00" align='center'>4 5</TH> - 네번째 + 다섯번째
</TR>
<TR>
<TH colspan='5' bgcolor="#FFFF00" align='center'>1 2 3 4 5</TH> - 난전부
</TR>


</TABLE>
</body>
</html>

--------------------------------------


이제 그래프같이 생긴 테이블3 파워복붙


<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<% request.setCharacterEncoding("utf-8"); %>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<style type="text/css">

* {

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<TABLE align='center' border="0" cellpadding="20px" cellspacing="5px">

<TR>

<TH></TH>

<TH></TH>

<TH></TH>

<TH></TH>

<TH></TH>

<TH rowspan='5' bgcolor='#AAFFAA'>6%</TH> - 맨 위에서 5번째 밑으로 병합 ㅇㅇ  아 -.-



</TR>

<TR>

<TH></TH>

<TH></TH>

<TH></TH>

<TH></TH>

<TH rowspan='4' bgcolor='#AAFFAA'>5%</TH>

</TR>

<TR>

<TH></TH>

<TH></TH>

<TH rowspan='3' bgcolor='#AAFFAA'>3%</TH>

<TH></TH>


</TR>

<TR>

<TH></TH>

<TH rowspan='2' bgcolor='#AAFFAA'>2%</TH>

<TH rowspan='2' bgcolor='#AAFFAA'>4%</TH> // 위에 애가 3을 먹어서 2  -> 4임 -.-) 췻

//이거 고통받으면 border 고쳐보고 확인해보면 쉬움맨

</TR>

<TR>

<TH rowspan='1' bgcolor='#AAFFAA'>1%</TH>

</TR>


</TABLE>

</body>

</html>




-------------------------12시!!! :>


리스트쩜 제이에스삐


<%@page import="java.sql.ResultSet"%>

<%@page import="java.sql.PreparedStatement"%>

<%@page import="java.sql.Connection"%>

<%@page import="java.sql.DriverManager"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>


<%

request.setCharacterEncoding("UTF-8");

String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";

//url 오타 조심


String id = "soldesk";

String password = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection(url, id, password);

PreparedStatement pstmt = null;


ResultSet rs = null;

String sql = null;

int cnt = 0;


sql = "SELECT memono, title, content, wdate, viewcnt ";

sql += "FROM memo ";

sql += "ORDER BY memono DESC ";


pstmt = con.prepareStatement(sql);


rs = pstmt.executeQuery();

//'ㅅ'

%>




<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<style>

* {

font-family: gulim;

font-size: 24px;

}

</style>


</head>

<body>

<DIV

style='font-size: 24px; text-align: center; text-decoration: underline; margin-top: 10px; margin-bottom: 20px;'>

메모 목록</DIV>


<Table align="center" border='1px' cellpadding="10px" cellspacing="0px">

<TR>

<TH>번호</TH>

<TH>제목</TH>

<TH>내용</TH>

<TH>조회수</TH>

</TR>


<%

if (rs.next() == false) {

%>

<TR>

<TD colspan='4'>등록된 메모가 없습니다.</TD>

</TR>

<%

} // end if

else {

do {

%>

<TR>

<TD><%=rs.getInt("memono")%></TD>

<TD><%=rs.getString("title")%></TD>

<TD><%=rs.getString("content")%></TD>

<TD><%=rs.getInt("viewcnt")%></TD>


</TR>


<%

} //end do

while (rs.next() == true);

} //end else

%>

</Table>


<DIV style='text-align: center; margin-top: 20px;'>

<input type="button" value='등록'

onclick="location.href='./createForm.jsp'">

</DIV>






</body>

</html>

<%

try {

if (rs != null) {

rs.close();

}

} catch (Exception e) {

}


try {

if (pstmt != null)

pstmt.close();

} catch (Exception e) {

}


try {

if (con != null)

con.close();

} catch (Exception e) {

}

%>



이게 그러니까

createForm - db에 등록하는 것

createProc - db에 계속 등록 or 목록 선택 가능한 것

list - 리스트로 출력



남의 컨텐츠를 보고 베낀 느낌이라 - 배우는 것

별로 기분이 안좋습니다




이제 수정할거임


<%@page import="java.sql.ResultSet"%>

<%@page import="java.sql.PreparedStatement"%>

<%@page import="java.sql.Connection"%>

<%@page import="java.sql.DriverManager"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>


<%

request.setCharacterEncoding("UTF-8");

String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";

//url 오타 조심


String id = "soldesk";

String password = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection(url, id, password);

PreparedStatement pstmt = null;


ResultSet rs = null;

String sql = null;

int cnt = 0;


sql = "SELECT memono, title, wdate, viewcnt ";

sql += "FROM memo ";

sql += "ORDER BY memono DESC ";


pstmt = con.prepareStatement(sql);


rs = pstmt.executeQuery();

//'ㅅ'

%>




<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<style>

* {

font-family: gulim;

font-size: 24px;

}

</style>


</head>

<body>

<DIV

style='font-size: 24px; text-align: center; text-decoration: underline; margin-top: 10px; margin-bottom: 20px;'>

메모 목록</DIV>


<Table align="center" border='1px' cellpadding="10px" cellspacing="0px">

<TR>

<TH>번호</TH>

<TH>제목</TH>

<TH>날짜</TH>

<TH>조회수</TH>

</TR>


<%

if (rs.next() == false) {

%>

<TR>

<TD colspan='4'>등록된 메모가 없습니다.</TD>

</TR>

<%

} // end if

else {

do {

%>

<TR>

<TD><%=rs.getInt("memono")%></TD>

<TD><%=rs.getString("title")%></TD>

<TD><%=rs.getString("wdate")%></TD>

<TD><%=rs.getInt("viewcnt")%></TD>


</TR>


<%

} //end do

while (rs.next() == true);

} //end else

%>

</Table>


<DIV style='text-align: center; margin-top: 20px;'>

<input type="button" value='등록'

onclick="location.href='./createForm.jsp'">

</DIV>






</body>

</html>

<%

try {

if (rs != null) {

rs.close();

}

} catch (Exception e) {

}


try {

if (pstmt != null)

pstmt.close();

} catch (Exception e) {

}


try {

if (con != null)

con.close();

} catch (Exception e) {

}

%>


이러면 날짜가 시분초까지 나오니까 그냥 날짜만 보여주고 싶으면


1. db에서 할 경우

2. 그냥 가져온 걸 출력 코드에서 수정할 경우




SELECT memono, title, content, to_char(wdate, 'yyyy-dd-mm'), viewcnt 

FROM memo  

ORDER BY memono ASC; 

 

sql문을 고치는 경우임 이건



sql = "SELECT memono, title, to_char(wdate, 'yyyy-dd-mm') wdate,  viewcnt ";

sql += " FROM memo ";

sql += "ORDER BY memono DESC ";


이건 출력 코드를 수정하는 건데

to_char(wdate, 'yyyy-dd-mm') wdate,  <- 이게 한 컬럼 -.-




-----------------------------12시 48분!!

이제 42분만 있으면 타코야키!! :>


아 진짜 제일 기쁘다 ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ

학원 와서 제일 기쁜 순간임


이제 35분만ㅇ ㅣㅆ으면 타코얔ㅋ키킼


에이씨 이거 그냥 원래 오류 있는 코드였음 

read.jsp


<%@page import="java.sql.*"%>


<%@ page language="java" contentType="text/html; charset=UTF-8" 

 pageEncoding="UTF-8"%>



<%

request.setCharacterEncoding("UTF-8");


int memono = Integer.parseInt(request.getParameter("memono"));

String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";

String id = "soldesk";

String pass = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection(url, id, pass);

PreparedStatement pstmt = null;

ResultSet rs = null;

String sql = null;

int cnt = 0;


// sql = "Select memono, title, content, to_char(wdate, 'yyyy-dd-mm') wdate, viewcnt";

sql = "select * ";

sql += "From memo Where memono = ? ";


pstmt = con.prepareStatement(sql);

pstmt.setInt(1, memono);


rs = pstmt.executeQuery();

String content = null;

String wdate = null;


if (rs.next()) {

content = rs.getString("content");

//얘만 가져온 이유는 변환하려고!

//뭐냐면 엔터나오면 라인스킵해주려고 :>

content = content.replaceAll("\r\n", "<br>");


wdate = rs.getString("wdate").substring(0, 10);

// substring(beginIndex, endIndex);

%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" 

content="text/html; charset=UTF-8">


<title>Insert title here</title>

<style type="text/css">

* {

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<DIV

style='font-size: 24px; text-align: center; 

text-decoration: underline; margin-top: 10px; 

margin-bottom: 20px;'>

조회</DIV>


<table align="center" border="1px" cellpadding="10px" 

cellspacing="0px">

<TR>

<TH>제목</TH>

<TD><%=rs.getString("title")%></TD>

</TR>

<TR>

<TH>내용</TH>

<TD><%=content%></TD>

</TR>

<TR>

<TH>조회수</TH>

<TD><%=rs.getString("viewcnt")%></TD>

</TR>

<TR>

<TH>등록일</TH>

<TD><%=rs.getString("wdate")%></TD>

</TR>

</table>


<DIV style='text-align: center; margin-top: 20px'>

<input type='button' value='등록'

onclick="location.href='./createForm.jsp'">

<input type='button' value='목록' 

onclick="location.href='./list.jsp'">

</DIV>







</body>

</html>


<%

} //일부러 위에서 안 닫고 열어놓은 거인가봄


try {

if (rs != null) {

rs.close();

}

} catch (Exception e) {


}


try {

if (pstmt != null) {

pstmt.close();


}

} catch (Exception e) {


}


try {

if (con != null) {

con.close();

}

} catch (Exception e) {


}

%>



이런 코드는

http://localhost:8000/memo/memo/read.jsp?memono=3

이렇게 파라미터 넣어줘야 되니까 구졌습니다

그래서 다른 방법으로 할 겁니다


---------------------

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@page import="java.sql.DriverManager"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<%
request.setCharacterEncoding("UTF-8");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
//url 오타 조심

String id = "soldesk";
String password = "1234";

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url, id, password);
PreparedStatement pstmt = null;

ResultSet rs = null;
String sql = null;
int cnt = 0;

sql = "SELECT memono, title, to_char(wdate, 'yyyy-dd-mm') wdate,  viewcnt ";
sql += " FROM memo ";
sql += "ORDER BY memono DESC ";

pstmt = con.prepareStatement(sql);

rs = pstmt.executeQuery();
//'ㅅ'
%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
* {
font-family: gulim;
font-size: 24px;
}
</style>
<script type="text/javascript">
function read(memono){
var url = "./read.jsp";
url = url + "?memono=" + memono;
//띄어쓰기 주의 -_-) ? memo = (x) ?memo= (o)
location.href = url; //자바스크립트에서 -get 방식- 링크 보내기
}

</script>

</head>
<body>
<DIV
style='font-size: 24px; text-align: center; text-decoration: underline; margin-top: 10px; margin-bottom: 20px;'>
메모 목록</DIV>

<Table align="center" border='1px' cellpadding="10px" cellspacing="0px">
<TR>
<TH>번호</TH>
<TH>제목</TH>
<TH>날짜</TH>
<TH>조회수</TH>
</TR>

<%
if (rs.next() == false) {
%>
<TR>
<TD colspan='4'>등록된 메모가 없습니다.</TD>
</TR>
<%
} // end if
else {
do {
%>
<TR>
<TD><%=rs.getInt("memono")%></TD>
<TD><a href = "javascript:read('<%=rs.getInt("memono")%>')"><%=rs.getString("title")%></a></TD>
<!-- 자바 스크립트 호출시 써줘야함 -->
<!--  "javascript:read('')" 요안에 표현식까지 다 복사해서 넣어야함
-->
<TD><%=rs.getString("wdate")%></TD>
<TD><%=rs.getInt("viewcnt")%></TD>

</TR>

<%
} //end do
while (rs.next() == true);
} //end else
%>
</Table>

<DIV style='text-align: center; margin-top: 20px;'>
<input type="button" value='등록'
onclick="location.href='./createForm.jsp'">
</DIV>





</body>
</html>
<%
try {
if (rs != null) {
rs.close();
}
} catch (Exception e) {
}

try {
if (pstmt != null)
pstmt.close();
} catch (Exception e) {
}

try {
if (con != null)
con.close();
} catch (Exception e) {
}
%>


리쓰트 jsp 고쳤습니다

이거 짱 복잡하넼ㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋㅋ


-----------------------------------------------타코야키 먹었음 (온화)


이제 조회수를 추가해봅시다.


sql = "update memo ";

sql += "set viewcnt = viewcnt + 1 ";

sql += "where memono = ? ";

pstmt = con.prepareStatement(sql);

pstmt.setInt(1, memono);

pstmt.executeUpdate();

// 조회수 증가하시는것

어 이거 read.jsp 임


<%@page import="java.sql.*"%>


<%@ page language="java" contentType="text/html; charset=UTF-8" 

 pageEncoding="UTF-8"%>



<%

request.setCharacterEncoding("UTF-8");


int memono = Integer.parseInt(request.getParameter("memono"));

String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";

String id = "soldesk";

String pass = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection(url, id, pass);

PreparedStatement pstmt = null;

ResultSet rs = null;

String sql = null;

int cnt = 0;


sql = "update memo ";

sql += "set viewcnt = viewcnt + 1 ";

sql += "where memono = ? ";

pstmt = con.prepareStatement(sql);

pstmt.setInt(1, memono);

pstmt.executeUpdate();

// 조회수 증가하시는것

sql = "select * ";

sql += "From memo Where memono = ? ";


pstmt = con.prepareStatement(sql);

pstmt.setInt(1, memono);


rs = pstmt.executeQuery();

String content = null;

String wdate = null;


if (rs.next()) {

content = rs.getString("content");

//얘만 가져온 이유는 변환하려고!

//뭐냐면 엔터나오면 라인스킵해주려고 :>

content = content.replaceAll("\r\n", "<br>");


wdate = rs.getString("wdate").substring(0, 10);

// substring(beginIndex, endIndex);

%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" 

content="text/html; charset=UTF-8">


<title>Insert title here</title>

<style type="text/css">

* {

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<DIV

style='font-size: 24px; text-align: center; 

text-decoration: underline; margin-top: 10px; 

margin-bottom: 20px;'>

조회</DIV>


<table align="center" border="1px" cellpadding="10px" 

cellspacing="0px">

<TR>

<TH>제목</TH>

<TD><%=rs.getString("title")%></TD>

</TR>

<TR>

<TH>내용</TH>

<TD><%=content%></TD>

</TR>

<TR>

<TH>조회수</TH>

<TD><%=rs.getString("viewcnt")%></TD>

</TR>

<TR>

<TH>등록일</TH>

<TD><%=rs.getString("wdate")%></TD>

</TR>

</table>


<DIV style='text-align: center; margin-top: 20px'>

<input type='button' value='등록'

onclick="location.href='./createForm.jsp'">

<input type='button' value='목록' 

onclick="location.href='./list.jsp'">

</DIV>







</body>

</html>


<%

} //일부러 위에서 안 닫고 열어놓은 거인가봄


try {

if (rs != null) {

rs.close();

}

} catch (Exception e) {


}


try {

if (pstmt != null) {

pstmt.close();


}

} catch (Exception e) {


}


try {

if (con != null) {

con.close();

}

} catch (Exception e) {


}

%>


-----------------------------요렇게 바꾸쉬는것


<%@ page import = "java.sql.*" %>

    

<% request.setCharacterEncoding("UTF-8"); %>


요걸 외우는거심


========================================


<%@page import="java.sql.*"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<%

request.setCharacterEncoding("UTF-8");

%>


<%

int memono = Integer.parseInt(request.getParameter("memono"));


String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";

String id = "soldesk";

String pass = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection(url, id, pass);

PreparedStatement pstmt = null;

ResultSet rs = null;

String sql = null;

int cnt = 0;


sql = "select * ";

sql += "From memo Where memono = ? ";


pstmt = con.prepareStatement(sql);

pstmt.setInt(1, memono);


rs = pstmt.executeQuery();

String content = null;


if (rs.next()) {

content = rs.getString("content");

%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

<style>

* {

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<DIV style="text-align: center; margin-top: 20px; margin-bottom: 20px;">

수정</DIV>


<form name="frm" method="POST" action="./updateProc.jsp">

<!-- 이거 보낸 다음에 where 안하면 모든 애들이 값이 다 똑같아짐... ㅠㅠㅠㅠ

어 이 개념 왜나왔지?

hidden 개념 :>! -암호화랑 상관없이 그냥 사용자양반이 보지 말라고 만드는 hidden

-->

 

<input type = "hidden" name = "memono" value = "<%=rs.getInt("memono")%> ">

<!-- 이거 없으면 이거 없다고 징징거림  -->

<table width="50%" align="center" border="1">

<tr>

<th>제목</th>

<td><input type='text' name='title' size='30'

value='<%=rs.getString("title")%>'></td>

</tr>


<tr>

<th>내용</th>

<td><textarea name='content' rows='10' cols='30'><%=rs.getString("content")%></textarea></td>

</tr>


</table>


<div

style="text-align: center; margin-top: 20px; margin-bottom: 20px;">

<input type="submit" value="전송">

</div>

</form>


</body>

</html>



<%

}

try {

if (rs != null) {

rs.close();

}

} catch (Exception e) {


}


try {

if (pstmt != null) {

pstmt.close();


}

} catch (Exception e) {


}


try {

if (con != null) {

con.close();

}

} catch (Exception e) {


}

%>


업데이트뽐 만들었음


이제 업데이트쁘록 만들거임

-------------------------------------

HTTP Status 500 - An exception occurred processing JSP page /memo/updateProc.jsp at line 9

이걸 참 많이 본다 ㅋㅋㅋㅋㅋㅋㅋㅋㅋ

연결 하는ㄱ ㅔ 넘나 어려운것...

JasperException

이게 그의 친구임


이제 list.jsp부터 실행해야함 -_-);;;;;;;

-------------------------------------------어쩄든 updateProc

<%@ page import="java.sql.*"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>

<%
request.setCharacterEncoding("UTF-8");

int memono = Integer.parseInt(request.getParameter("memono"));
String title = request.getParameter("title");
String content = request.getParameter("content");
String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
String user = "soldesk";
String password = "1234";

Class.forName("oracle.jdbc.driver.OracleDriver");
//패키지는 ㄷㅐ문자가 없음... - OracleDriver 가 대문자니까 클래스임 'ㅅ'

Connection con = DriverManager.getConnection(url, user, password);
PreparedStatement pstmt = null;
String sql = "";

sql = "UPDATE memo ";
sql += "SET title = ?, ";
sql += "content = ? ";
sql += "WHERE memono = ? ";

pstmt = con.prepareStatement(sql);
pstmt.setString(1, title);
pstmt.setString(2, content);
pstmt.setInt(3, memono);

int cnt = pstmt.executeUpdate();
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>

</head>
<body>

<DIV style='font-size: 24px; text-align: center; margin-top: 100px;'>
<%
if (cnt == 1) {
out.println("메모를 수정 했습니다.");
} else {
out.println("메모 수정에 실패했습니다.");
}
%>
<br> <input type='button' value='계속 등록'
onclick="location.href='./createForm.jsp'"> <input
type='button' value='목록' onclick="location.href='./list.jsp'">
</DIV>

</body>
</html>

<%
try {
if (pstmt != null) {
pstmt.close();

}
} catch (Exception e) {

}

try {
if (con != null) {
con.close();
}
} catch (Exception e) {

}
%>



------------------------------------------------------------updateProc이었습니다

<%@page import="java.sql.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
%>

<%
int memono = Integer.parseInt(request.getParameter("memono"));

String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
String id = "soldesk";
String pass = "1234";

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url, id, pass);
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
int cnt = 0;

sql = "select * ";
sql += "From memo Where memono = ? ";

pstmt = con.prepareStatement(sql);
pstmt.setInt(1, memono);

rs = pstmt.executeQuery();
String content = null;

if (rs.next()) {
content = rs.getString("content");
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
* {
font-family: gulim;
font-size: 24px;
}
</style>
</head>
<body>
<DIV style="text-align: center; margin-top: 20px; margin-bottom: 20px;">
수정</DIV>

<form name="frm" method="POST" action="./updateProc.jsp">
<!-- 이거 보낸 다음에 where 안하면 모든 애들이 값이 다 똑같아짐... ㅠㅠㅠㅠ
어 이 개념 왜나왔지?
hidden 개념 :>! -암호화랑 상관없이 그냥 사용자양반이 보지 말라고 만드는 hidden
-->
 
<!--  <input type = "hidden" name = "memono" value = "< % =rs.getInt("memono") % > ">
이거 rs로 받으면 오류나고 그냥 value 값으로 받아줘야함
-->
 <input type='hidden' name='memono' size='30' value='<%=memono %>'>
 
<!-- 이거 없으면 이거 없다고 징징거림  -->
<table width="50%" align="center" border="1">
<tr>
<th>제목</th>
<td><input type='text' name='title' size='30'
value='<%=rs.getString("title")%>'></td>
</tr>

<tr>
<th>내용</th>
<td><textarea name='content' rows='10' cols='30'><%=rs.getString("content")%></textarea></td>
</tr>

</table>

<div
style="text-align: center; margin-top: 20px; margin-bottom: 20px;">
<input type="submit" value="전송">
</div>
</form>

</body>
</html>


<%
}
try {
if (rs != null) {
rs.close();
}
} catch (Exception e) {

}

try {
if (pstmt != null) {
pstmt.close();

}
} catch (Exception e) {

}

try {
if (con != null) {
con.close();
}
} catch (Exception e) {

}
%>


-------------------------------------------------------------updateForm 이었습니다


이 부분에 열받는건


<!--  <input type = "hidden" name = "memono" value = "< % =rs.getInt("memono") % > ">

이거 rs로 받으면 오류나고 그냥 value 값으로 받아줘야함

-->

 <input type='hidden' name='memono' size='30' value='<%=memono %>'>


이게 문제였다는 거야 으아아 이게뭔뎅ㅇㅇㅇㅇㅇㅇㅇㅇㅇㅇ


으아아 표현식 ^^


------------------------------- David이 헷갈리는 ResultSet


http://kyumboy.tistory.com/40




--아 이거 질문하고 다시 쓰겠음 레이디



------------------------------------------------------------------------------

DELETE는 복붙할겁미다

<%@ page contentType="text/html; charset=UTF-8"%>


<% request.setCharacterEncoding("utf-8"); %>


<%

int memono = Integer.parseInt(request.getParameter("memono"));

%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title></title>

<style type="text/css">

* {

font-family: gulim;

font-size: 24px;

}

</style>

</head>

<body>

<DIV style='text-align: center; margin-top: 20px; margin-bottom: 20px;'>삭제

확인</DIV>


<Form name='frm' method='POST' action='./deleteProc.jsp'>

<input type='hidden' name='memono' size='30' value='<%=memono %>'>


<DIV

style='text-align: center; margin-top: 20px; margin-bottom: 20px;'>

삭제를 하면 복구 될 수 없습니다.<br>

<br> 삭제하시려면 삭제 처리 버튼을 클릭하세요.<br>

<br> 취소는 '목록' 버튼을 누르세요. <br>

<br> <input type='submit' value='삭제 처리'> <input

type='button' value='목록' onclick="location.href='./list.jsp'">

</DIV>

</Form>

<!-- 성생님이 굳이 뽐으로 안써도 된다 구랬는대 선생님이 이렇게 만드럿슴니다 

저는 전ㅅㅎㅕㅑ 쉽지가 안습니다 씪씪

그 리절트셋이 다시 고통받고이습니다

그리고 선언문이 머리가 아픔미다

선언문이 아니라표현식

으아아ㅏ 왜 이름도 이러ㅏㅎ게 미낭낭

ㄴㅁㅇㄴㅁㅇㅁㄴ

-->


</body>

</html>



--------------------저건 디리트뽐

이 아래는 디리트 쁘록
<%@ page contentType="text/html; charset=UTF-8"%>

<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.DriverManager"%>
<%@ page import="java.sql.PreparedStatement"%>

<% request.setCharacterEncoding("utf-8"); %>

<%
int memono = Integer.parseInt(request.getParameter("memono"));
 
// String url = "jdbc:oracle:thin:@172.16.12.100:1521:XE";
String url = "jdbc:oracle:thin:@soldesk-PC:1521:XE";
String id = "soldesk";
String pass = "1234";
 
Class.forName("oracle.jdbc.driver.OracleDriver"); // ojdbc6.jar
Connection con=DriverManager.getConnection(url, id, pass);
PreparedStatement pstmt=null; // SQL 실행 능력
String sql = null;
int cnt = 0;
 
sql  = " DELETE FROM memo";
sql += " WHERE memono = ?";
 
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, memono);
 
cnt = pstmt.executeUpdate(); // 삭제 실행
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<style type="text/css">
* {
font-family: gulim;
font-size: 24px;
}
</style>
</head>
<body>
<DIV style='font-size: 24px; text-align: center; margin-top: 100px;'>
<%
  if (cnt == 1){
    out.println("메모를 삭제 했습니다.");
  }else{
    out.println("메모 삭제에 실패했습니다.");
  }
  %>
<br> <input type='button' value='목록'
onclick="location.href='./list.jsp'">
</DIV>

</body>
</html>

<%
try{
  if (pstmt != null){
    pstmt.close();
  
  }
}catch(Exception e){
  
}
 
try{
  if (con != null){
    con.close();
  }
}catch(Exception e){
  
}
%>


------------------------------------------------------------------아 이거 언제 다 읽어 으아아

그리고 리드에 가서 이거 수정해줌

<%@page import="java.sql.*"%>

<%@ page language="java" contentType="text/html; charset=UTF-8" 
 pageEncoding="UTF-8"%>


<%
request.setCharacterEncoding("UTF-8");

int memono = Integer.parseInt(request.getParameter("memono"));
String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";
String id = "soldesk";
String pass = "1234";

Class.forName("oracle.jdbc.driver.OracleDriver");
Connection con = DriverManager.getConnection(url, id, pass);
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
int cnt = 0;

sql = "update memo ";
sql += "set viewcnt = viewcnt + 1 ";
sql += "where memono = ? ";
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, memono);
pstmt.executeUpdate();
// 조회수 증가하시는것
sql = "select * ";
sql += "From memo Where memono = ? ";

pstmt = con.prepareStatement(sql);
pstmt.setInt(1, memono);

rs = pstmt.executeQuery();
String content = null;
String wdate = null;

if (rs.next()) {
content = rs.getString("content");
//얘만 가져온 이유는 변환하려고!
//뭐냐면 엔터나오면 라인스킵해주려고 :>
content = content.replaceAll("\r\n", "<br>");

wdate = rs.getString("wdate").substring(0, 10);
// substring(beginIndex, endIndex);
%>


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" 
content="text/html; charset=UTF-8">

<title>Insert title here</title>
<style type="text/css">
* {
font-family: gulim;
font-size: 24px;
}
</style>


<script type = "text/javascript">
function updateM(){
var url = "updateForm.jsp";
url += "?memono=<%=memono%>";
location.href = url;
//혼파망...-_-);
}

function deleteM(){
var url = "deleteForm.jsp";
url += "?memono=<%=memono%>";
location.href = url;
}

</script>

</head>
<body>
<DIV
style='font-size: 24px; text-align: center; 
text-decoration: underline; margin-top: 10px; 
margin-bottom: 20px;'>
조회</DIV>

<table align="center" border="1px" cellpadding="10px" 
cellspacing="0px">
<TR>
<TH>제목</TH>
<TD><%=rs.getString("title")%></TD>
</TR>
<TR>
<TH>내용</TH>
<TD><%=content%></TD>
</TR>
<TR>
<TH>조회수</TH>
<TD><%=rs.getString("viewcnt")%></TD>
</TR>
<TR>
<TH>등록일</TH>
<TD><%=rs.getString("wdate")%></TD>
</TR>
</table>

<DIV style='text-align: center; margin-top: 20px'>
<input type='button' value='등록'
onclick="location.href='./createForm.jsp'">
<input type='button' value='목록' 
onclick="location.href='./list.jsp'">
<input type='button' value='수정' 
onclick="updateM()">
<!-- on으롷 시작하는 함수는 그냥 자바스크립트 취급이라서
< % % > 안써도 됨
-->
 
<input type='button' value='삭제' 
onclick="deleteM()"> 
 
</DIV>






</body>
</html>

<%
} //일부러 위에서 안 닫고 열어놓은 거인가봄

try {
if (rs != null) {
rs.close();
}
} catch (Exception e) {

}

try {
if (pstmt != null) {
pstmt.close();

}
} catch (Exception e) {

}

try {
if (con != null) {
con.close();
}
} catch (Exception e) {

}
%>


---------------------------------------------------------------



지금 저 연결하는 놈의 거랑 close 부분 include로 바꾸면 짱편하시셈



[10][메모장] 메모장 version 2.0으로 업그레이드, SSI(Server Side Include)
[01] SSI(Server Side Include) 
     - 하나 이상의 jsp페이지에서 반복적으로 사용되는 코드를 모아 
       특정 jsp페이지에 저장해두고, 필요시에 추가하여 사용하는 방법을 말합니다. 

     - 처리 결과가 합쳐지는 것이 아니라 파일의 소스가 하나의 파일에 합쳐진 다음 
       실행됩니다. 
      
     list.jsp 소스 + ssi.jsp 소스 = jsp 통합 큰 소스 ==> 실행 
     --------------------------------------------------------   

   - 사용 방법 
     <%@ include file="Local URL" %> 

     <%@ include file="./ssi.jsp" %> 

   
     


            

    


   


-  Eclipse Project: memo 계속 사용 
   Folder Name: /WebContent/memov2 
   Library: WEB-INF/lib/ojdbc14.jar or ojdbc6.jar 



★ SSI 파일의 사용의 경우 아래의 Page Directive는 포함되는 JSP 및 포함하는  
   JSP 파일 모두 대소문자 및 공백도 일치해야합니다. 

  <%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 

  <%@ page contentType="text/html; charset=UTF-8" %>  

  위의 2가지를 혼합하여 사용하면 안되고 한가지 패터만 사용, 공백도 문제됨. 


ㅇㅇ 띄어쓰기 & 대소문자 구분을 잘 해야 합니다 ^^


아 이전에 memo v2 라는 폴더를 하나 만들었음


ssi.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@page import="java.sql.*"%>



<%

request.setCharacterEncoding("UTF-8");



String url = "jdbc:oracle:thin:@127.0.0.1:1521:XE";


String id = "soldesk";

String password = "1234";


Class.forName("oracle.jdbc.driver.OracleDriver");

Connection con = DriverManager.getConnection(url, id, password);

PreparedStatement pstmt = null;


ResultSet rs = null;

String sql = null;

int cnt = 0;

%>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>Insert title here</title>

</head>

<body>


</body>

</html>



그담에 ssi_dbclose.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>

</body>
</html>
<%
try {
if (rs != null) {
rs.close();
}
} catch (Exception e) {
}

try {
if (pstmt != null)
pstmt.close();
} catch (Exception e) {
}

try {
if (con != null)
con.close();
} catch (Exception e) {
}
%>


<!-- 이거 리드의 시체와 리스트의 시체입니다. -->



요렇게 만들어놓고


리쓰트 쥐에쓰피에 가서


<%@ page language="java" contentType="text/html; charset=UTF-8"

pageEncoding="UTF-8"%>

<%@ include file = "./ssi.jsp" %>


<%



sql = "SELECT memono, title, to_char(wdate, 'yyyy-dd-mm') wdate,  viewcnt ";

sql += " FROM memo ";

sql += "ORDER BY memono DESC ";


pstmt = con.prepareStatement(sql);


rs = pstmt.executeQuery();

//'ㅅ'

%>


이런 식으로 인클루드 해주면 됨 ㅋㅋㅋㅋ

<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file = "./ssi.jsp" %>

<%
sql = "SELECT memono, title, to_char(wdate, 'yyyy-dd-mm') wdate,  viewcnt ";
sql += " FROM memo ";
sql += "ORDER BY memono DESC ";

pstmt = con.prepareStatement(sql);

rs = pstmt.executeQuery();
//'ㅅ'
%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<style>
* {
font-family: gulim;
font-size: 24px;
}
</style>
<script type="text/javascript">
function read(memono){
var url = "./read.jsp";
url = url + "?memono=" + memono;
//띄어쓰기 주의 -_-) ? memo = (x) ?memo= (o)
location.href = url; //자바스크립트에서 -get 방식- 링크 보내기
}

</script>

</head>
<body>
<DIV
style='font-size: 24px; text-align: center; text-decoration: underline; margin-top: 10px; margin-bottom: 20px;'>
메모 목록</DIV>

<Table align="center" border='1px' cellpadding="10px" cellspacing="0px">
<TR>
<TH>번호</TH>
<TH>제목</TH>
<TH>날짜</TH>
<TH>조회수</TH>
</TR>

<%
if (rs.next() == false) {
%>
<TR>
<TD colspan='4'>등록된 메모가 없습니다.</TD>
</TR>
<%
} // end if
else {
do {
%>
<TR>
<TD><%=rs.getInt("memono")%></TD>
<TD><a href = "javascript:read('<%=rs.getInt("memono")%>')"><%=rs.getString("title")%></a></TD>
<!-- 자바 스크립트 호출시 써줘야함 -->
<!--  "javascript:read('')" 요안에 표현식까지 다 복사해서 넣어야함
-->
<TD><%=rs.getString("wdate")%></TD>
<TD><%=rs.getInt("viewcnt")%></TD>

</TR>

<%
} //end do
while (rs.next() == true);
} //end else
%>
</Table>

<DIV style='text-align: center; margin-top: 20px;'>
<input type="button" value='등록'
onclick="location.href='./createForm.jsp'">
</DIV>





</body>
</html>

<%@ include file = "./ssi_dbclose.jsp"%>

이렇게 생겼음






--------------뭐야 오늘 뭔가 배우다 말았는걸 










5. 수업

진도: 

hw: 


6. 할것

토요일 나가기 전에 볼 것 다운받아 놓을 것... -_-);;

마저 보고 놀아야 함미다


이기쥬히 - 팀원이 추천한 부로그 

ㄴ 좋은 점 : 자료가 많음

ㄴ 나쁜 점 : 비밀번호가 걸려있음







주말에 도서관가서 자발적으로 하드코딩 해 볼 것...

안그러면 넥x트x 처럼 머리가 혼돈스러울 것이야




resultset


귀찮으니까 듀얼모니터 쓰게 줄 꺼내놓기 - DVI? -.- 쪼만한 단자 어딨더랑 'ㅅ'




'Programming' 카테고리의 다른 글

160412: 22회차  (0) 2016.04.12
160408: 20회차  (1) 2016.04.08
160406: 18회차  (3) 2016.04.06
160405: 17회차  (3) 2016.04.05
160404: 16회차  (4) 2016.04.04
Posted by DAVID
블로그 이미지

by DAVID

공지사항

    최근...

  • 포스트
  • 댓글
  • 트랙백
  • 더 보기

태그

글 보관함

«   2025/06   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30

링크

카테고리

PC (112)
Programming (109)

카운터

Total
Today
Yesterday
방명록 : 관리자 : 글쓰기
DAVID's Blog is powered by daumkakao
Skin info material T Mark3 by 뭐하라
favicon

PC

  • 태그
  • 링크 추가
  • 방명록

관리자 메뉴

  • 관리자 모드
  • 글쓰기
  • PC (112)
    • Programming (109)

카테고리

PC화면 보기 티스토리 Daum

티스토리툴바