JÈëÃÅ:¸÷ÖÖÊý¾Ý¿âÁ¬½ÓµÄʵÀý´úÂë_JSP¼¼ÇÉ_ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØ--Powered by WWW.RONGSEN.COM.CN

JÈëÃÅ:¸÷ÖÖÊý¾Ý¿âÁ¬½ÓµÄʵÀý´úÂë

×÷ÕߣººÚ¿Í·ÀÏßÍø°²JSP½Ì³Ì»ùµØ À´Ô´£ººÚ¿Í·ÀÏßÍø°²JSP½Ì³Ì»ùµØ ä¯ÀÀ´ÎÊý£º0

±¾Æª¹Ø¼ü´Ê£ºÊµÀý´úÂëÁ¬½ÓÊý¾Ý¿â
ºÚ¿Í·ÀÏßÍø°²ÍøѶ£ºÏÖÔÚÓкöà³õѧjspµÄÍøÓѾ­³£»áÎÊÊý¾Ý¿âÔõôÁ¬½Ó°¡£¬ÔõôÀϳö´í°¡£¿ËùÒÔÎÒ¼¯ÖеÄÔÚÕâдƪÎÄÕ¹©´ó¼Ò²Î¿¼£¬ÆäʵÕâÖÖ°ÑÊý¾Ý¿âÂß¼­È«²¿·ÅÔÚjspÀïδ±ØÊǺõÄ×ö·¨£¬µ«ÊÇÓÐÀûÓÚ³õѧÕßѧϰ£¬ËùÒÔÎÒ...

ÏÖÔÚÓкöà³õѧjspµÄÍøÓѾ­³£»áÎÊÊý¾Ý¿âÔõôÁ¬½Ó°¡£¬ÔõôÀϳö´í°¡£¿ËùÒÔÎÒ¼¯ÖеÄÔÚÕâдƪÎÄÕ¹©´ó¼Ò²Î¿¼£¬ÆäʵÕâÖÖ°ÑÊý¾Ý¿âÂß¼­È«²¿·ÅÔÚjspÀïδ±ØÊǺõÄ×ö·¨£¬µ«ÊÇÓÐÀûÓÚ³õѧÕßѧϰ£¬ËùÒÔÎÒ¾ÍÕâÑù×öÁË£¬µ±´ó¼Òѧµ½Ò»¶¨³Ì¶ÈµÄʱºò£¬¿ÉÒÔ¿¼ÂÇÓÃMVCµÄģʽ¿ª·¢¡£ÔÚÁ·Ï°ÕâЩ´úÂëµÄʱºò£¬ÄãÒ»¶¨½«jdbcµÄÇý¶¯³ÌÐò·Åµ½·þÎñÆ÷µÄÀà·¾¶ÀȻºóÒªÔÚÊý¾Ý¿âÀィһ¸ö±ítest,ÓÐÁ½¸ö×ֶαÈÈçΪtest1£¬test2£¬¿ÉÒÔÓÃÏÂÃæSQL½¨

create table test(test1 varchar(20),test2 varchar(20)

È»ºóÏòÕâ¸ö±íдÈëÒ»Ìõ²âÊԼͼ£¬ÄÇôÏÖÔÚ¿ªÊ¼ÎÒÃǵÄjspºÍÊý¾Ý¿âÖ®Âðɡ£

Ò»¡¢jspÁ¬½ÓOracle8/8i/9iÊý¾Ý¿â£¨ÓÃthinģʽ£©

testoracle.jspÈçÏ£º

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();
String url="jdbc:oracle:thin:@localhost:1521:orcl";
//orclΪÄãµÄÊý¾Ý¿âµÄSID
String user="scott";
String password="tiger";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º<%=rs.getString(1)%>
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º<%=rs.getString(2)%>
<%}%>
<%out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>
¶þ¡¢jspÁ¬½ÓSql Server7.0/2000Êý¾Ý¿â

testsqlserver.jspÈçÏ£º

<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver").newInstance();
String url="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=pubs";
//pubsΪÄãµÄÊý¾Ý¿âµÄ
String user="sa";
String password="";
Connection conn= DriverManager.getConnection(url,user,password);
Statement stmt=conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
String sql="select * from test";
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()) {%>
ÄúµÄµÚÒ»¸ö×Ö¶ÎÄÚÈÝΪ£º<%=rs.getString(1)%>
ÄúµÄµÚ¶þ¸ö×Ö¶ÎÄÚÈÝΪ£º<%=rs.getString(2)%>
<%}%>
<%out.print("Êý¾Ý¿â²Ù×÷³É¹¦£¬¹§Ï²Äã");%>
<%rs.close();
stmt.close();
conn.close();
%>
</body>
</html>

    ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤·½°¸±¾ÆªÁ¬½Ó£ºhttp://www.rongsen.com.cn/show-16691-1.html
Íøվά»¤½Ì³Ì¸üÐÂʱ¼ä:2012-04-07 00:44:57  ¡¾´òÓ¡´ËÒ³¡¿  ¡¾¹Ø±Õ¡¿
ÎÒÒªÉêÇë±¾Õ¾£ºNµã | ºÚ¿Í·ÀÏß¹ÙÍø |  
רҵ·þÎñÆ÷ά»¤¼°Íøվά»¤ÊÖ¹¤°²È«´î½¨»·¾³£¬ÍøÕ¾°²È«¼Ó¹Ì·þÎñ¡£ºÚ¿Í·ÀÏßÍø°²·þÎñÆ÷ά»¤»ùµØÕÐÉ̽øÐÐÖУ¡QQ:29769479

footer  footer  footer  footer