锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美精品系列,日本中文字幕一区,日韩精品一区二区三区第95http://www.aygfsteel.com/huanat/come here!zh-cnThu, 19 Jun 2025 15:28:45 GMTThu, 19 Jun 2025 15:28:45 GMT60Jsp榪炴帴Mysql鏁版嵁搴?甯﹁繛鎺ユ睜) http://www.aygfsteel.com/huanat/archive/2006/07/14/58130.htmlhuanathuanatFri, 14 Jul 2006 03:26:00 GMThttp://www.aygfsteel.com/huanat/archive/2006/07/14/58130.htmlhttp://www.aygfsteel.com/huanat/comments/58130.htmlhttp://www.aygfsteel.com/huanat/archive/2006/07/14/58130.html#Feedback0http://www.aygfsteel.com/huanat/comments/commentRss/58130.htmlhttp://www.aygfsteel.com/huanat/services/trackbacks/58130.html
Property
Value
jdbc/mysql

鍦╟onf/server.xml涓緗涓嬶細

聽聽聽聽聽聽聽 <Context
聽聽聽聽聽聽聽聽聽聽聽 docBase="D:/myjsp"
聽聽聽聽聽聽聽聽聽聽聽 path="/myjsp">
聽聽聽聽聽聽聽聽聽 <ResourceLink
聽聽聽聽聽聽聽聽聽聽聽 global="jdbc/mysql"
聽聽聽聽聽聽聽聽聽聽聽 name="jdbc/mysql"
聽聽聽聽聽聽聽聽聽聽聽 type="javax.sql.DataSourcer"/>
聽聽聽聽聽聽聽 </Context>

:::::::::鎺ョ潃鍙互浣跨敤浜?:::::::

<%@ page contentType="text/html; charset=GBK" language="java"聽 errorPage="" %>
<%@ page session="false"%>
<%@ page import="java.sql.*"%>
<%@ page import="javax.sql.*"%>
<%@ page import="javax.naming.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>鏃犳爣棰樻枃妗?lt;/title>
</head>

<body>
<%
/** statment搴旂敤瀹炰緥
Connection conn=null;
Statement sm=null;
ResultSet rs=null;
try
{
聽聽 InitialContext ctx=new InitialContext();
聽聽 DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
聽聽 conn=ds.getConnection();
聽聽 sm=conn.createStatement();
聽聽 rs=sm.executeQuery("select * from go");聽聽
聽聽 while(rs.next())
聽聽 {
聽聽聽聽聽 out.println(rs.getString(2)+"....."+rs.getInt("id")+"</br>");
聽聽聽 }
}catch(Exception e){
聽聽 e.printStackTrace();
}finally{
聽if(sm!=null)
聽{
聽聽sm.close();
聽}聽
聽if(conn!=null){
聽聽conn.close();
聽}
}
*/
/**preparestatement搴旂敤瀹炰緥
InitialContext ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
Connection conn=ds.getConnection();
PreparedStatement psm=conn.prepareStatement("insert into go(name,sex) values(?,?)");
psm.setString(1,"鍗庡摜");
psm.setString(2,"鑻遍泟");
psm.executeUpdate();
psm.close();
conn.close();
out.println("鏇存柊鎴愬姛");

InitialContext ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
Connection conn=ds.getConnection();
PreparedStatement psm=conn.prepareStatement("update go set name=? where id=?");
psm.setString(1,"澶╀嬌");
psm.setInt(2,2);
psm.executeUpdate();
out.println("鏇存柊鎴愬姛!");
psm.close();
conn.close();
*/
InitialContext ctx=new InitialContext();
DataSource ds=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");
Connection conn=ds.getConnection();
Statement sm=conn.createStatement();
ResultSet rs=sm.executeQuery("select * from go");
while(rs.next())
{
聽out.println(rs.getString(1)+"..."+rs.getString(2)+"..."+"</br>");
}
sm.close();
rs.close();
conn.close();
%>
</body>
</html>



huanat 2006-07-14 11:26 鍙戣〃璇勮
]]>
主站蜘蛛池模板: 凯里市| 双鸭山市| 疏附县| 青田县| 高邮市| 铁岭县| 佛学| 绍兴市| 周口市| 蒙山县| 伽师县| 天气| 海伦市| 盘山县| 安溪县| 崇义县| 南安市| 瑞安市| 伊金霍洛旗| 武汉市| 太和县| 平乡县| 宽甸| 秦安县| 佛冈县| 奉化市| 望谟县| 永城市| 游戏| 双峰县| 怀仁县| 柘城县| 黄大仙区| 安福县| 长武县| 福鼎市| 文昌市| 建阳市| 漯河市| 营山县| 大新县|