Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

MysqlͨÓòéѯ²Ù×÷Àà(Jsp+servlet+javaBean+Mysql)

ÔÚÌÚ¿ÆÅàѵÁËÓÐ1¸ö°ëÔÂÁË£¬ÖÕÓÚѧÍêJSP+SERVLET+JAVABEAN+MYSQL£¬Ñ§ÁËjavaµÄµÚÒ»Ì×web½â¾ö·½°¸¡£ÀÏʦҪÇóÎÒÃÇ6ÈËÒ»×鿪ʼ×öÒ»¸ö¶©²Íϵͳ¡£Õâ¸öϵͳûÓÐʲôÌرðµÄ£¬¾Í¸úµç×ÓÉ̳ÇÊÇÒ»¸öÑùµÄ¡£ÓÉÓÚÒª¶ÔÊý¾Ý¿â×ö´óÁ¿µÄÔöɾ¸Ä²é£¬ÄǸö´úÂëÓֶ࣬ÎÒÏëÄܲ»Äܽ«Êý¾Ý¿â²Ù×÷µÄÕâÒ»²ã´ò°üÆðÀ´(SqlOperDao)£¬ÈÃÎÒ¶ÔÊý¾Ý¿â²Ù×÷£¬Óü¸ÐдúÂë¾Í¸ã¶¨µÄ¡£È»ºóÎÒÖ»ÐÞ¸ÄsqlÓï¾ä£¬ºÍ´«½øÀ´µÄ²ÎÊý¾Í¿ÉÒÔÁË¡£
Ôöɾ¸ÄÊôÓÚÒ»Àà²Ù×÷£¬¶¼ÊDz»·µ»Ø½á¹û¼¯µÄ£¬¶ø²éÕÒÊÇÒª·µ»Ø½á¹û¼¯µÄ
1£©ÏÈ˵Ôöɾ¸ÄµÄ²Ù×÷
public int buildConn(String sql)throws Exception{
  Connection conn=null;
  Statement stmt=null;
   int result=0;
  boolean flag;
   try{
   conn=sqlconn.conn();
   stmt=conn.createStatement();
      result=stmt.executeUpdate(sql);
   System.out.println("¹§Ï²ÄãÖ´Ðгɹ¦"+result+"Ìõ¼Ç¼£¡");
   flag=true;
  }catch(Exception e){
   System.out.println("±§Ç¸£¡Ö´ÐÐʧ°Ü£¡"+e.getMessage());
   flag=false;
  }finally{
   
   stmt.close();
   conn.close();
  }
  return result;
 }
2£©¶ø¶ÔÓÚ²éѯ²Ù×÷µÄ¾Í±È½ÏÂé·³Ò»µã£¬Í¨³£ÎÒÃǶ¼½«²éѯµÄ½á¹û¼¯´ò°üµ½Ò»¸öjavabean×éºÏÖУ¬ÀýÈçÎÒÓÐÒ»¸öµÇ½µÄjavabeanÀïÃæÖ»ÓÐnameºÍpassword£¬¶ÔÓ¦µÄ±íÖÐuser_listµÄÁ½ÁÐname,password.ÏÖÔÚÒª½«user_listÖеÄËùÓÐÊý¾Ý¶Á³öÀ´£¬¶Á³öÒ»Ìõ£¬¾Í·Åµ½Ò»¸öjavabeanÖУ¬¶àÌõÊý¾Ý¾Í·Åµ½List<javabean>ÖС£Ê×ÏÈÎÒÃÇ¿ÉÒÔ½²Êý¾Ý¿âÖеÄËùÓÐÊý¾Ý¶¼ÓöÁÈ¡×Ö·û´®µÄÐÎʽgetStringµÄ·½·¨¶Á³öÀ´£¬µ±È»Èç¹ûÊý¾Ý¿âÖбíµÄÁеÄÊôÐÔ²»ÊÇvarcharÀàÐÍ£¬¾Í²»¿ÉÒÔÓôËÀà·½·¨¡£
±¾Í¨ÓòéѯֻÕë¶Ô¶¼ÊÇStringÀàÐÍµÄ±í¡£
 /**
  * ͨÓòéѯ£¬´«ÈëÒª²éѯµÄsqlÓï¾ä
  * ·µ»ØÒ»¸öList<String[]>
  */
 public List<String[]> query(String sql) throws Exception{
  this.queryList=new ArrayList<String[]>();
  Statement stmt = null;
  ResultSet rs = null;
     Connection conn=null;
&n


Ïà¹ØÎĵµ£º

jsp Ò³ÃæÇ建´æ


<%
response.setHeader("Pragma","No-cache");
response.setHeader("Cache-Control","no-cache");
response.setDateHeader("Expires", 0);
%>
<meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http- ......

Mysql²éѯʱ£¬¶ÔÓÚÊýÖµÐÍ×ֶμӵ¥ÒýºÅ»áÒýÆðµÄÎó½â¡«

¼ÙÉèÓбí tb1
ID £ü name£ü
----+--------+
1   £ü2toon£ü
2   £ü1*xyz£ü
Óï¾ä1£º
 select * from  tb1 where ID='2toon' or name ='2toon';
mysql·þÎñÆ÷ÔÚijģʽÏ£¬¿ÉÒÔÖ´ÐÐÕâÌõ¾ä£¬¾Í³É¹¦·µ»ØÁ½Ìõ¼Ç¼£¬Ô­ÒòÔÚÓÚ ID=‘2toon’ ¼ÓÁ˵¥ÒýºÅ£¬mysql½âÊÍΪ ID=2.
Óï¾ä2
select * fro ......

mysql,sqlserver,oracleÈýÖÖÊý¾Ý¿âµÄ´ó¶ÔÏó´æÈ¡


mysql ´ó¶ÔÏó´æÈ¡:
ÀàÐÍÒ»°ãÓ¦¸ÃÓÃmediumblod,
blobÖ»ÄÜ´æ2µÄ16´Î·½¸öbyte,
mediumblodÊÇ24´Î·½,
Ò»°ãÀ´Ëµ¹»ÓÃÁË.longblobÊÇ32´Î·½ÓÐЩ´ó.
MYSQLĬÈÏÅäÖÃÖ»ÄÜ´æ1M´óСµÄÎļþ,ÒªÐÞ¸ÄÅäÖÃ,WIN°æ±¾µÄÔÚmysql.iniÎļþÖÐ
ÐÞ¸Ämax_allowed_packet,net_buffer_lengthµÈ¼¸¸ö²ÎÊý,»òÖ±½ÓSET GLOBAL varName=value.
linux°æ± ......

JSPÒþ²Ø¶ÔÏó½éÉÜ


1.request¶ÔÏó
¿Í»§¶ËµÄÇëÇóÐÅÏ¢±»·â×°ÔÚrequest¶ÔÏóÖУ¬Í¨¹ýËü²ÅÄÜÁ˽⵽¿Í»§µÄÐèÇó£¬È»ºó×ö³öÏìÓ¦¡£ËüÊÇHttpServletRequestÀàµÄʵÀý¡£
ÐòºÅ ·½ ·¨ ˵ Ã÷
1 object getAttribute(String name) ·µ»ØÖ¸¶¨ÊôÐÔµÄÊôÐÔÖµ
2 Enumeration getAttributeNames() ·µ»ØËùÓпÉÓÃÊôÐÔÃûµÄö¾Ù
3 String getCharacterEncoding() · ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ