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

JSPʵÏÖ¼òÒ×µÄSQL±¨±í

ÊäÈë: select ID as ±àºÅ, NAME as ÐÕÃû, AGE as ÄêÁä from XXX
Êä³ö:
񅧏
ÐÕÃû
ÄêÁä
 
 
 
ÒªÇóÊÇÈç¹ûSQL±ä¶¯, ÈÔȻҪÏÔʾ³öÀ´ËùÓеıðÃû×Ö¶ÎÐÅÏ¢ºÍÊý¾Ý.
ÒòΪÏÖÔÚHibernateÓõıȽϹ㷺, ËùÒÔÓÅÏÈ¿¼ÂÇÓÃHibernateÀ´ÊµÏÖ, ½á¹û·¢ÏÖÈç¹ûÊÇʵÌåÓ³Éä²éѯÓï¾ä, ¿ÉÒÔ·½±ãµÄÓÃ:List<String> Query.getReturnAliases() »ñµÃ±ðÃû, È»¶øÎÒÃÇÖªµÀ²éѯʱÓÐʱºòÓï¾äÊǺܸ´ÔÓµÄ, ²»È«ÊÇHQL, ÕâʱºòÓÃSQLQueryµÄʱºò, ¾ªÑȵÄÌáʾÕâ¸ö·½·¨ÉÐδʵÏÖ(×îаæµÄHibernate 3.3 ÊÇ·ñʵÏÖÉÐδ²âÊÔ), Óõİ汾ÊÇHibernate 3.2, ¶ÔÓ¦µÄ´úÂëÊÇ:
DAO
/**
* ¸ù¾Ý²éѯÓï¾ä·µ»Ø½á¹û, ²¢°üº¬½á¹ûµÄÁÐÃû
* @param hql
* @param args
* @return
*/
public List queryAllForReport( final String hql, final Object... args) {
List list = getHibernateTemplate().executeFind(new HibernateCallback() {
public Object doInHibernate(Session session)
throws HibernateException, SQLException {
Query query = session.createQuery(hql);

for(int i =0; i < args.length; i++) {
query.setParameter(i, args[i]);
}

List list = query.list();
list.add(0, query.getReturnAliases());

return list;
}
});

// Hibernate×öcount¼ÆËã·µ»ØÒ»°ã¶¼ÊǶÔÏó

return list;
}
²âÊÔ´úÂë:
List<Object[]> list = dao.queryAllForReport("select id as ±àºÅ, name as µÇ¼Ãû, address as µØÖ·, realName from User");
System.out.println(list.size());
for(Object[] row : list) {
for(Object v : row) {
System.out.print(v + "\t");

}

System.out.println();
}
×îºó²»µÃ²»»Øµ½JDBC, Óà ResultSetºÍResultSetMetaDataʵÏÖÁËÕâ¸ö¹¦ÄÜ, Ïêϸ´úÂë(×Ô¼º½øÐÐÐ޸ļ´¿ÉʵÏÖ)ÈçÏÂ:
<%@ page language="java" import="java.util.*, java.sql.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>SQL±¨±í&l


Ïà¹ØÎĵµ£º

JUnitѧϰ±Ê¼Ç14 ¶ÔJSPºÍtaglib½øÐе¥Ôª²âÊÔ1

                                                  A tes ......

½²½âJSP¹ýÂËÆ÷ºÍ¼àÌýÆ÷

     ¹ØÓÚÕâ¸öÎÊÌâ, ±È½Ï¸´ÔÓµÄ˵. ²»¹ýÎÒÏ£Íûͨ¹ýÀý×ÓÀ´½âÊͻ᷽±ãÀí½âһЩ.
¼ÙÉèÓÐÒ»¸ö·Ç³£Î£ÏÕµÄÈÎÎñ, ÊǾÅËÀÒ»Éú. ÐèÒªÄã´§×ÅÕ¨Ò©°ü´Ó±±Æ½¿ª³µ×߸ßËÙ·¹ý±£¶¨È¥Ê¯¼Òׯ°Ñ¹í×ӵĵﱤ¸øÕ¨ÁË. ×¢Òâ: Õâ¸öÈÎÎñÊ®·Ö¼è¾Þ, ÓпÉÄÜ°ë·ըҩ±¬Õ¨. ËùÒÔ³ö·¢Ç°ÄãÐèÒª¿àÁ·10ÔªÒ»±¾µÄ<<Ìú²¼ÉÀ>>, » ......

Óà MyEclipse ¿ª·¢µÄ Hibernate + JSP ·ÖÒ³´úÂë

ÏÂÔغóµ¼ÈëÏîÄ¿µ½ MyEclipse , È»ºóÐÞ¸ÄÊý¾Ý¿âÁ¬½Ó²ÎÊý¼´¿É²âÊÔ. ÎÒÕâÓõÄÊÇ MySQL Êý¾Ý¿â. Óà JSP ÊÇÒòΪ Hibernate ¿ÉÒÔÅäºÏ¸÷ÖÖ¿ò¼Ü, Òò´ËÔÚ´úÂëÀïÎÒÒѾ­¾¡Á¿µÄ°ÑÒ³ÃæºÍºǫ́µÄÖ±½Ó±äÁ¿ñîºÏ·Ö¸ô¿ªÁË.
hibernate_page.zip 433KB
²¿·Ö´úÂëÏÔʾ:
Ïà¹Ø SQL:
CREATE TABLE `user` (
`id` int(11) NOT NULL,
`u ......

ÍêȫжÔØSQL Server 2005

SQL Server 2005£¨ÊÊÓÃÓÚ2000£©µÄжÔØÊÇÒ»¸ö·Ç³£Í·ÌÛµÄÎÊÌâ¡£ÎÒÔø¾­³¢ÊÔ¹ýÖ±½ÓʹÓá¾Ìí¼Ó»òɾ³ý³ÌÐò¡¿¹¤¾ßжÔØ¡¢Çå³ý°²×°Ä¿Â¼¡¢É¾³ý×¢²á±íÄÚÈݵȵȸ÷ÖÖ·½Ê½×ÛºÏжÔØ£¬ÃãÇ¿³É¹¦¡£ÏÖÔÚÖÕÓÚÕÒµ½ÁËÒ»¸öÊ°빦±¶µÄ·½·¨£¬¶à´Î³¢ÊÔ£¬Î´ÓÐʧ°Ü,¾ßÌåÈçÏÂ:
1.ÏÂÔØжÔع¤¾ß£¬ÓÐÁ½ÖÖ£º
µÚÒ»ÖÖÊÇ΢Èí¹Ù·½ÌṩµÄ¹¤¾ß(msicuu2.exe)
http ......

Ô¶³ÌÁ¬½Ósql server 2000·þÎñÆ÷µÄ½â¾ö·½°¸

Ô¶³ÌÁ¬½Ósql server 2000·þÎñÆ÷µÄ½â¾ö·½°¸
                                        ----ת×Ô£º·ÉºüСÎÝ
ÓÉÓ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ