Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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


Ïà¹ØÎĵµ£º

JSP Éú³ÉËæ»úÑéÖ¤ÂëͼƬ


<%@ page contentType="image/jpeg" import="java.awt.*,java.awt.image.*,java.util.*,javax.imageio.*" %>
<%!
Color getRandColor(int fc,int bc){//¸ø¶¨·¶Î§»ñµÃËæ»úÑÕÉ«
Random random = new Random();
if(fc>255) fc=255;
if(bc>255) bc=255;
int r=fc+random.nextInt(bc-fc);
int g=fc+ran ......

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

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

Çë½ÌÒ»¸ösql²éѯÎÊÌâ ×Ó²éѯ=ÏÔʾµÚ¶þÌõÐÅÏ¢

create database test --½¨Á¢testÊý¾Ý¿â
use test
create table BONUS --½¨Á¢
(
ENAME NVARCHAR(10),
JOB NVARCHAR(9),
SAL FLOAT,
COMM FLOAT
)
create table DEPT --½¨Á¢²¿Ãűí
(
DEPTNO SMALLINT not null, --²¿ÃűàºÅ
DNAME NVARCHAR(14), --²¿ÃÅÃû
LOC NVARC ......

My PL/SQL practice 8/2/10

SQLPlus  :http://www.orafaq.com/wiki/SQL*Plus_FAQ
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/sqloperations.htm
1. Transfer values from a sql scripts:
   CNT=`sqlplus -s username/password1@dbname @getUVQuery_NULLCNT`;
 
   Note : Remeber to use o ......

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

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