|
|
|
รบกวนผู้รู้ช่วยคอมเม้นโค๊ดนี้ให้ผมหน่อยคับอยากศึกษา jsp + oracle คับ |
|
|
|
|
|
|
|
แล้วถ้าจะเปลี่ยนเป็น insert ต้องเปลี่ยนตรงใหนบ้างคับ
Code (Java-JSP)
<%@ page import="java.io.*,java.sql.*,java.text.*,java.util.*,thaitran.MultipartRequest" %>
<%@ page contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ page import="java.util.Date,java.util.Calendar"%>
<%@ page import="sun.util.BuddhistCalendar,java.text.SimpleDateFormat"%>
<%@ page import="java.sql.SQLException"%>
<%@ page import="java.sql.Connection"%>
<%@ page import="java.sql.ResultSet"%>
<%@ page import="java.sql.Statement"%>
<%@ page import="thaitran.DBUtils"%>
<%! private String getString(String str,String def) {
if(str != null) return str;
return def;
}
%>
<%
response.setContentType("text/html");
//Prevent the browser from caching the response.
response.setHeader("Pragma", "no-cache"); // HTTP 1.0
response.setHeader("Cache-Control", "no-cache"); // HTTP 1.1
session = request.getSession(true);
Object done6 = session.getAttribute("con");
if(done6 == null) {
response.sendRedirect("../../index.jsp");
return;
}
Connection con = (Connection)done6;
DBUtils db = new DBUtils(con);
//out.print("con = "+con+"<br>");
Statement stmt = null;
stmt = con.createStatement();
%>
<%
String CUSTOMER2 = "";
//String CUSTOMER2 = getString(request.getParameter("CUSTOMER2"),"");
ResultSet rsdetail = db.getResult("SELECT CUSTOMERID, NAME, EMAIL FROM CUSTOMER2",stmt);
if(rsdetail.next()) {
CUSTOMER2 = getString(rsdetail.getString("CUSTOMERID"),"");
}db.close(rsdetail);//rsdetail.close();
out.print(CUSTOMER2);
%>
<html>
<head>
<title>ThaiCreate.Com JSP Tutorial</title>
</head>
<body>
<%
//out.println("<br>"+ CUSTOMERID);
%>
<%
db.close(stmt);
%>
</body>
</html>
Tag : Java, JSP
|
|
|
|
|
|
Date :
2014-07-07 12:06:13 |
By :
newtt |
View :
1174 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Code นี้ไม่มีอะไรวับซ้อนเลยครับ ลองเข้าไปอ่าน Java กับ Oracle ก่อนครับ
Java Connect to Oracle Database (JDBC)
|
|
|
|
|
Date :
2014-07-07 13:11:03 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|