일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 | 31 |
- mysql
- tomcat
- wildfly
- JSP
- 웹화상회의
- 화상회의
- 줌 채팅
- postgresql
- openmeetings
- 아파치 오픈미팅
- 줌 개발
- ubuntu
- 데이터베이스
- zoom sdk
- zoom OkHttp
- 명령어
- apache openmeetings
- jboss
- db
- centos
- zoom OkHttpClient
- 줌 녹화
- 아파치 openmeetings
- zoom api
- zoom
- zoom 서버통신
- java
- centos7
- 리눅스
- AWS
- Today
- Total
StartIT
jsp, postgresql 연동으로 db를 tomcat서버에서 접근하기(update) 본문
//modify.jsp//
<%@page contentType="text/html;charset=utf-8" import="java.sql.*" %>
<%
request.setCharacterEncoding("utf-8");
String num=request.getParameter("num");
String url = "jdbc:postgresql://서버주소/디비명";
String usr = "유저명";
String pwd = "password";
String name="",email="",phone="";
int age=0;
Connection con = null;
Statement stmt = null;
ResultSet rs = null;
try
{
Class.forName("org.postgresql.Driver");
con = DriverManager.getConnection(url, usr, pwd);
stmt = con.createStatement();
String query="select * from 테이블명 where num = " + num;
rs = stmt.executeQuery(query);
while(rs.next()){
name = rs.getString("name");
email = rs.getString("email");
phone = rs.getString("phone");
age = rs.getInt("age");
}
%>
<HTML>
<HEAD></HEAD>
<BODY>
<FORM action="modify_do.jsp?num=<%=num%>" method="post">
이름: <INPUT type="text" name="name" maxlength="3" size="3" value="<%=name%>"><br>
나이: <INPUT type="text" onKeyUp="this.value=this.value.replace(/[^0-9]/g.'')" name="age" maxlength="2" size="2" value="<%=age%>"><br>
e-mail 주소: <INPUT type="text" name="email" size="24" value="<%=email%>"><br>
전화번호: <INPUT type="text" name="phone" maxlength="14" size="14" value="<%=phone%>"><br>
<INPUT type="submit" value="저장">
<INPUT type="submit" value="취소" onclick="javascript: form.action='list.jsp';">
</FORM>
</BODY>
</HTML>
<%
rs.close();
stmt.close();
con.close();
}
catch (SQLException e){
out.println("err:"+e.toString());
}
%>
//modify_do.jsp//
<%@page contentType="text/html;charset=utf-8" import="java.sql.*" %>
<%
request.setCharacterEncoding("utf-8");
String url = "jdbc:postgresql://서버주소/디비명";
String usr = "유저명";
String pwd = "password";
String num1=request.getParameter("num");
String age1=request.getParameter("age");
String name=request.getParameter("name");
String email=request.getParameter("email");
String phone=request.getParameter("phone");
int num = Integer.parseInt(num1);
int age = Integer.parseInt(age1);
Connection con = null;
try
{
con = DriverManager.getConnection(url, usr, pwd);
String sql = "UPDATE 테이블명 set 칼럼명=?, 칼럼명=?, 칼럼명=?, 칼럼명=? where 칼럼명 = ?";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1,name);
pstmt.setInt(2,age);
pstmt.setString(3,email);
pstmt.setString(4,phone);
pstmt.setInt(5,num);
pstmt.executeUpdate();
pstmt.close();
con.close();
}
catch(SQLException e)
{
out.println(e);
}
response.sendRedirect(list.jsp");
%>
'Server > centos' 카테고리의 다른 글
jsp, postgresql 연동으로 db를 tomcat서버에서 접근하기(delete) (0) | 2020.06.29 |
---|---|
jsp, postgresql 연동으로 db를 tomcat서버에서 접근하기(Insert) (0) | 2020.06.29 |
centos7 명령어들 (0) | 2020.06.29 |
jsp, postgresql 연동으로 db를 tomcat서버에서 접근하기(select) (0) | 2020.06.29 |
centos7 tui,gui 변경 (0) | 2020.06.29 |