SlideShare une entreprise Scribd logo
1  sur  29
1
.JSP
Eclipse
1. Eclipse
2. AppServ 2.5.10 Java
eclipse MySQL
- AppServ 2.5.10
Appserv
2
Next >
License Agreement AppServ 2.5.10
I Agree
3
Next >
Select Components
Next >
HTTPServer
4
ServerName : localhost
Email: E-mail
Port: 80
Next >
MySQL
5
Install
Windows Security Alert Allow
access
6
Finish
appserv
web server
7
browser localhost
3. Navicat
MySQL localhost
http://www.navicat.com/download/d
ownload.html
8
Next
I accept the agreement Next
(
9
Next
Next
10
Next >
Install
11
Finish Navicat
4. Java Eclipse
(MySQL)
4.1 project 1project project
BookMark
4.2 package 2package Package
comment Package controller
- Package comment java class class
connect
package comment;
12
importjava.sql.DriverManager;
importjava.sql.SQLException;
importjava.sql.Statement;
importjava.sql.Connection;
importjava.util.logging.Level;
importjava.util.logging.Logger;
public class connect {
public Connection conn =null;
public Statement stmt = null;
public Statement getStatement(){
returnstmt;}
public void createConnection() throws
SQLException{
try{
Class.forName("com.mysql.jdbc.Driver");
13
conn =
DriverManager.getConnection("jdbc:mysql://localhost/b
ook","root","admin");
stmt= conn.createStatement();
System.out.println("Connect success.");
}catch(ClassNotFoundException ex) {
Logger.getLogger(connect.class.getName()).l
og(Level.SEVERE, null, ex);
System.out.println("Connect Fail.");
}
}
public void closeConnection(){
try{
conn.close();
}catch(SQLException ex){
Logger.getLogger(connect.class.getName()).l
14
og(Level.SEVERE, null, ex);
} }
}
- package controller servlet
loginservlet import classconnect
loginservlet
packagecom.controller;
importjava.io.IOException;
importjava.sql.SQLException;
importjavax.servlet.ServletException;
importjavax.servlet.annotation.WebServlet;
importjavax.servlet.http.HttpServlet;
importjavax.servlet.http.HttpServletRequest;
importjavax.servlet.http.HttpServletResponse;
importcomment.connect;
Servlet implementation class LoginServlet
15
@WebServlet("/LoginServlet")
public class LoginServlet extends HttpServlet {
private static final long serialVersionUID = L;
Default constructor.
publicLoginServlet() {
TODO Auto-generated constructor stub
} @see HttpServlet#doGet(HttpServletRequest
request, HttpServletResponse response)
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws
ServletException, IOException {
TODO Auto-generated method stub
} @see
HttpServlet#doPost(HttpServletRequest request,
HttpServletResponse response)
protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws
16
ServletException, IOException {
TODO Auto-generated method stub
String username = request.getParameter("id");
String password =
request.getParameter("password");
System.out.println("username="+username);
System.out.println("password="+password);
connectdb = new connect();
try {
db.createConnection();
} catch (SQLException e) {
TODO Auto-generated catch block
e.printStackTrace();
} }
}
17
4.3) Java.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>
<h1>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</h1>
18
<center>
<form action="LoginServlet" method="post"
onsubmit="return check()">
<table>
<tr>
<td align="right">User</td>
<td><input type="text" name="id" ><br></td>
</tr>
<tr>
<td align="right">Password</td>
<td><input type="password" name="password"
><br></td>
</tr>
<tr>
<td align="center" colspan="2">
19
<input type="submit" name="ok" value=" >
<br></td>
<!--
<tr>
<td align="right"> </td>
<td><input type="text" name="Firstname"
id="Firstname"><br></td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="text" name="lastname"
id="lastname"><br></td>
</tr>
<tr>
<td align="right"> </td>
20
<td><input type="radio" checked="checked"
name="sex" value=" > <input type="radio"
name="sex" value=" > <br></td>
</tr>
<tr>
<td align="right"> </td>
<td>
<input type="checkbox" name="cartoon"
value=" >
<input type="checkbox" name="cartoon"
value=" >
<input type="checkbox" name="cartoon"
value=" >
<input type="checkbox" name="cartoon"
value=" >
<br></td></tr>
21
<tr>
<td align="right" > </td>
<td><textarea name="Address"
id="Address"></textarea><br></td>
</tr>
<tr>
<td align="right"> </td>
<td><select name="Province">
<option
value=" > </option>
<option value=" > </option>
<option value=" > </option>
<option value=" > </option>
<option value=" > </option>
<option value=" > </option>
22
</select><br></td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="text" name="number"
id="number"><br></td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="text" name="email"
id="email"><br></td>
</tr>
<tr>
<td align="right"> </td>
<td><input type="file" id="image"><br></td>
23
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" name="ok" value=" >
<input type="reset"name="delete" value=" >
<br></td>
</tr> </table>
</form></center>
</body></html>
5. MySQL Navicat
1.
24
Navicat Connection
Connection
Connection Name: Connection
Host name/IP address: localhost
Port:
User name: User name MySQL
root
Password: MySQL
Test Connection
Conection Successfully
OK
2.
25
connection
MySQL connection
New Database
Create New Database
Enter database name:
Character set: utf8–UTF-8
Unicode
26
Collation: Collation utf8_general_ci
OK
Navicat
1. Navicat
Tables => New
Table
27
28
29

Contenu connexe

Tendances

JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
haruki ueno
 

Tendances (17)

Asp.net tips
Asp.net tipsAsp.net tips
Asp.net tips
 
Vagrant plugin development intro
Vagrant plugin development introVagrant plugin development intro
Vagrant plugin development intro
 
Nodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web ApplicationsNodejs Intro - Part2 Introduction to Web Applications
Nodejs Intro - Part2 Introduction to Web Applications
 
My Database Skills Killed the Server
My Database Skills Killed the ServerMy Database Skills Killed the Server
My Database Skills Killed the Server
 
Secure Your Wordpress
Secure Your WordpressSecure Your Wordpress
Secure Your Wordpress
 
Session on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh GundechaSession on Selenium Powertools by Unmesh Gundecha
Session on Selenium Powertools by Unmesh Gundecha
 
Backbase CXP Manager Setup
Backbase CXP Manager SetupBackbase CXP Manager Setup
Backbase CXP Manager Setup
 
Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)Testing with Codeception (Webelement #30)
Testing with Codeception (Webelement #30)
 
Tomcat
TomcatTomcat
Tomcat
 
Htaccess info
Htaccess infoHtaccess info
Htaccess info
 
Workshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and JavaWorkshop MSF4J - Getting Started with Microservices and Java
Workshop MSF4J - Getting Started with Microservices and Java
 
Workshop WSO2 BPS 3.5.x - BPMN
Workshop WSO2 BPS 3.5.x - BPMN Workshop WSO2 BPS 3.5.x - BPMN
Workshop WSO2 BPS 3.5.x - BPMN
 
Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)Chrome Devtools Protocol via Selenium/Appium (Japanese)
Chrome Devtools Protocol via Selenium/Appium (Japanese)
 
PowerShell-2
PowerShell-2PowerShell-2
PowerShell-2
 
How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)How to Configure Selenium WebDriver (java)
How to Configure Selenium WebDriver (java)
 
JavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオンJavaDo#09 Spring boot入門ハンズオン
JavaDo#09 Spring boot入門ハンズオン
 
The Play Framework at LinkedIn
The Play Framework at LinkedInThe Play Framework at LinkedIn
The Play Framework at LinkedIn
 

Similaire à การเข ยนโปรแกรมต ดต_อฐานข_อม_ล

Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
Adil Jafri
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
Spiffy
 
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docxJava Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
priestmanmable
 
I really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdfI really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdf
amitbagga0808
 

Similaire à การเข ยนโปรแกรมต ดต_อฐานข_อม_ล (20)

Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes AhmedabadJava Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
Java Training Ahmedabad , how to Insert Data in Servlet, iOS Classes Ahmedabad
 
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
자바 웹 개발 시작하기 (1주차 : 웹 어플리케이션 체험 실습)
 
Ta Javaserverside Eran Toch
Ta Javaserverside Eran TochTa Javaserverside Eran Toch
Ta Javaserverside Eran Toch
 
Servlet 3.0
Servlet 3.0Servlet 3.0
Servlet 3.0
 
Rich Portlet Development in uPortal
Rich Portlet Development in uPortalRich Portlet Development in uPortal
Rich Portlet Development in uPortal
 
Web based development
Web based developmentWeb based development
Web based development
 
JSP Error handling
JSP Error handlingJSP Error handling
JSP Error handling
 
ASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin LauASP.NET Overview - Alvin Lau
ASP.NET Overview - Alvin Lau
 
JSR 168 Portal - Overview
JSR 168 Portal - OverviewJSR 168 Portal - Overview
JSR 168 Portal - Overview
 
Solving anything in VCL
Solving anything in VCLSolving anything in VCL
Solving anything in VCL
 
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docxJava Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
Java Advance 4deleteQuery.PNGJava Advance 4deleteQuerySucc.docx
 
Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5Dave Orchard - Offline Web Apps with HTML5
Dave Orchard - Offline Web Apps with HTML5
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
I really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdfI really need help on this question.Create a program that allows t.pdf
I really need help on this question.Create a program that allows t.pdf
 
Jsp and jstl
Jsp and jstlJsp and jstl
Jsp and jstl
 
Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6Integrating Wicket with Java EE 6
Integrating Wicket with Java EE 6
 
WebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemonWebTalk - Implementing Web Services with a dedicated Java daemon
WebTalk - Implementing Web Services with a dedicated Java daemon
 
Web-Performance
Web-PerformanceWeb-Performance
Web-Performance
 
May 2010 - RestEasy
May 2010 - RestEasyMay 2010 - RestEasy
May 2010 - RestEasy
 
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 MinutesBuild Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
Build Your First Java Jersey JAX-RS REST Web Service in less than 15 Minutes
 

Plus de Bongza Naruk

รายงานพรีเซน Sessioncookie
รายงานพรีเซน Sessioncookieรายงานพรีเซน Sessioncookie
รายงานพรีเซน Sessioncookie
Bongza Naruk
 
การเพ มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sql
การเพ  มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sqlการเพ  มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sql
การเพ มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sql
Bongza Naruk
 
Sec.1 กล ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปร
Sec.1 กล  ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปรSec.1 กล  ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปร
Sec.1 กล ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปร
Bongza Naruk
 

Plus de Bongza Naruk (6)

รายงานพรีเซน Sessioncookie
รายงานพรีเซน Sessioncookieรายงานพรีเซน Sessioncookie
รายงานพรีเซน Sessioncookie
 
Jsp
JspJsp
Jsp
 
ภาษา Jsp
ภาษา Jspภาษา Jsp
ภาษา Jsp
 
การเพ มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sql
การเพ  มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sqlการเพ  มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sql
การเพ มข_อม_ลลงฐานข_อม_ลด_วยภาษา jsp&sql
 
Update&delete
Update&deleteUpdate&delete
Update&delete
 
Sec.1 กล ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปร
Sec.1 กล  ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปรSec.1 กล  ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปร
Sec.1 กล ม 1 เร__องการสร_างแบบฟอร_มและการส_งค_าต_วแปร
 

Dernier

Dernier (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 

การเข ยนโปรแกรมต ดต_อฐานข_อม_ล