일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- centos7
- postgresql
- zoom api
- zoom sdk
- 줌 채팅
- centos
- db
- 아파치 openmeetings
- 명령어
- 줌 개발
- 데이터베이스
- openmeetings
- zoom
- 리눅스
- java
- 웹화상회의
- mysql
- zoom 서버통신
- AWS
- JSP
- 줌 녹화
- 화상회의
- ubuntu
- zoom OkHttp
- jboss
- wildfly
- apache openmeetings
- 아파치 오픈미팅
- tomcat
- zoom OkHttpClient
- Today
- Total
StartIT
jsp, postgresql 연동으로 db를 tomcat서버에서 접근하기(Insert) 본문
//input.jsp//
<%@ page contentType="text/html; charset=utf-8" %>
<HTML>
<HEAD></HEAD>
<BODY>
<FORM action="save_do.jsp" method="post">
이름: <INPUT type="text" name="name" maxlength="3" size="3"><br>
나이: <INPUT type="text" onKeyUp="this.value=this.value.replace(/[^0-9]/g.'')" name="age" maxlength="2" size="2"><br>
e-mail 주소: <INPUT type="text" name="email" size="24"><br>
전화번호: <INPUT type="text" name="phone" maxlength="14" size="14"><br>
<INPUT type="submit" value="저장">
</FORM>
</BODY>
</HTML>
//save_do.jsp//
<%@ page contentType="text/html; charset=utf-8" import="java.sql.*" %>
<%
request.setCharacterEncoding("utf-8");
String url = "jdbc:postgresql://서버주소/db명";
String usr = "유저명";
String pwd = "password";
Class.forName("org.postgresql.Driver");
Connection con = null;
String name = request.getParameter("name");
String age1 = request.getParameter("age");
String email = request.getParameter("email");
String phone = request.getParameter("phone");
int age=0;
if(!age1.equals("")) = Integer.parseInt(age1);
try
{
con = DriverManager.getConnection(url, usr, pwd);
String sql = "INSERT INTO 테이블명(컬럼명,컬럼명...) VALUES(?,?,?,?)";
PreparedStatement pstmt = con.prepareStatement(sql);
pstmt.setString(1,name);
pstmt.setInt(2,age);
pstmt.setString(3,email);
pstmt.setString(4,phone);
pstmt.executeUpdate();
pstmt.close();
con.close();
}
catch(SQLException e)
{
out.println(e);
}
response.sendRedirect("list.jsp");
%>
참고:
https://hahahia.tistory.com/94?category=446168
JSP, DB연동을 이용한 회원리스트 구현(회원추가)
/* input.jsp */ /* 앞에서 목록생성을 한 list에서 저장링크를 누르면 나오는 페이지입니다(회원가입)*/ <%@ page contentType="text/html;charset=utf-8" %> ID : 이름 : PW : /* save_do.jsp */ <%@ page cont..
hahahia.tistory.com
'Server > centos' 카테고리의 다른 글
jsp, postgresql 연동으로 db를 tomcat서버에서 접근하기(update) (0) | 2020.06.29 |
---|---|
jsp, postgresql 연동으로 db를 tomcat서버에서 접근하기(delete) (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 |