buk.jsp

来自「一个简单的旅游自助系统」· JSP 代码 · 共 40 行

JSP
40
字号
<%@ page language="java" contentType="text/html; charset=gb2312"
    pageEncoding="gb2312"%>
<html>
<head><title>预约</title><head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<body>
<hr>
<h4>信息:</h4>
<%@ page import="java.sql.*"%>
<%
try{
request.setCharacterEncoding("gb2312");
int id=Integer.parseInt(request.getParameter("id"));
String name=request.getParameter("name");
String str;
String datauser="root";                     
String datapw="L0VEXING";   
Class.forName("org.gjt.mm.mysql.Driver").newInstance(); 
String url ="jdbc:mysql://localhost/luyou?user="+datauser+"&password="+datapw+"&useUnicode=true&characterEncoding=GB2312" ;
Connection con= DriverManager.getConnection(url); 
Statement sm=con.createStatement();
str="insert into buk values("+id+",'"+name+"')";
sm.executeUpdate(str);
out.print("<center><h3>预约成功</h3></center>");
sm.close();
con.close();

}
catch(Exception e)
{
	out.print("未知错误,请联系管理员");
}
%>
<hr>
<table width="100%" border="0" cellpadding="0" align="center">
<tr>
<td align="center"><a href="index.html" title="返回">返回</a></td>
</tr></table>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?