jspÁ¬½ÓMySQLÊý¾Ý¿â 2
¡ñjspÁ¬½ÓMySQLÊý¾Ý¿â
testmysql.jspÈçÏ£º
<%@ page contentType="text/html;charset=gb2312"%>
<%@ page import="java.sql.*"%>
<html>
<body>
<%Class.forName("org.gjt.mm.mysql.Driver").newInstance();
String url ="jdbc:mysql://localhost/softforum?
user=soft&password=soft1234&useUnicode=true&characterEncoding=8859_1"
//testDBΪÄãµÄÊý¾Ý¿âÃû
Connection conn= DriverManager.getConnection(url);
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>
Ïà¹ØÎĵµ£º
²éѯ¼°É¾³ýÖظ´¼Ç¼µÄ·½·¨
(Ò»)
1¡¢²éÕÒ±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´ÅжÏ
select * from people
where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2¡¢É¾³ý±íÖжàÓàµÄÖظ´¼Ç¼£¬Öظ´¼Ç¼ÊǸù¾Ýµ¥¸ö×ֶΣ¨peopleId£©À´Åжϣ¬Ö»Á ......
Ö÷ÒªµÄ³ÌÐò£º
package greeds.jdbc.sample;
import greeds.jdbc.util.JDBCUtil;
import java.io.*;
import java.sql.*;
public class MySQLBlobSample {
public static void main(String[] args) throws Exception {
// дÈëÊý¾Ý¿â
/*
*
* Connection ......
el±í´ïʽ·ÖÀà
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
·Ö Àà ¹¦ÄÜ·ÖÀà ±êÇ©Ãû³Æ
Core ±í´ïʽ²Ù×÷ out
set
remove
catch
Á÷³Ì¿ØÖÆ if
......
½ñÌìÔÚѧϰjspÖÐÊý¾Ý¿âµÄʹÓÃʱ£¬Óöµ½Ò»¸öºÜÆæ¹ÖµÄÇé¿ö£¨ÖÁÉÙÏÖÔÚ¿´À´Êǵģ©¡£jspÖÐÁ¬½ÓmysqlÊý¾Ý¿â£¬¿ªÆômysqlÊý¾Ý¿âºó£¬ÔÚjspÒ³ÃæÖÐǶÈëµÄjavaÁ¬½ÓmysqlÊý¾Ý¿âµÄÄǼ¸¾ä´úÂë¡£ºÃÏñ Class.forName("org.gjt.mm.mysql.Driver");ûÆðµ½×÷Óã¬Ö»ÐèÒªConnection con=DriverManager.getConnection("jdbc:mysql://localhost/test? ......
½üÈÕ£¬MySQL 5.5 µÚÒ»¸ö°æ±¾·¢²¼ÁË£¬»ùÓÚMySQl 5.4£¬µ«ÊÇÔÚÐÔÄÜÉÏÏà¶ÔÓÚµ±Ç°µÄ5.0/5.1ÓÐÁ˺ܴóµÄÌáÉý¡£
ÐÂÌØÐÔ£º
Ö§³Ösemisynchronous £¨°ëͬ²½£©¸´Öƽӿڣ¬¿É´î½¨³öÒ»¸öÏà¶ÔÍêÃÀµÄMySQL¸ß¿ÉÓÃÐÔ·½°¸
¼¯³ÉInnodb plugin 1.0.6
Ö§³Ö SQL ±ê×¼ SIGNAL ºÍ RESIGNAL Óï¾ä
ÔöÇ¿XML¹¦ÄÜ£¬Ö§³Ö LOAD XML Óï¾ä
¿Éͨ¹ý A ......