hibernateÖ´ÐÐÔÉúSqlÓï¾äµÄ·½·¨£¨×ª£©
http://www.thecloud.cn/study/program/java/597.html
hibernate3µÄHQL ÊÇÃæÏò¶ÔÏóµÄÓï·¨,ÒѾ֧³Ö update ,delete fromÓï¾ä,µ«
Ä¿Ç°»¹²»Ö§³Öinsert intoÓï¾ä.
×öÏîÄ¿ÓÐʱºòµÄÈ·ÐèҪдÔÉúµÄsqlÀ´·½±ãweb¿ª·¢.
ÏÂÃæÊÇÎÒ×Ô¼º¹Äµ·³öÀ´µÄ·½·¨,Ï£Íû¶ÔÎÒºÍÅóÓÑÓÐËù°ïÖú.
ÔÚDaoÀïдһ¸ö·½·¨,ÈÃÎÒÃÇÔÚactionÀïµ÷ÓÃËü...
public void InsertData(String MytblName,String
Mytitle,String Mycode,String Mycoments){
log.debug("insert into dataitems ---drs");
//ʹÓÃÁËÔÉúsqlÓï¾ä
try{
//½«´«ÈëµÄÀàÃû´¦Àí³É±íÃû ÀýÈç:CTable----¡µC_Table
MytblName = "C_"+MytblName.substring(1,MytblName.length());
//²åÈë±í µÄ
sql
String Insert_SQL ="INSERT INTO "+MytblName+
"
(C_Title,C_Code,C_Comments)"+
" VALUES
('"+Mytitle+"','"+Mycode+"','"+Mycoments+"')" ;
//»ñµÃµ±Ç°sessionµÄÊý¾Ý¿âÁ¬½Ó
Connection
CurConn =
getSession().connection();
//System.out.println(Insert_SQL);
//Éú³ÉÒ»¸öStatement¶ÔÏó
PreparedStatement ps = CurConn.prepareStatement(Insert_SQL);
//Ö´Ðвéѯ
ps.execute();
//¹Ø±Õ¸Ã¶ÔÏó
ps.close();
getSession().flush();
log.debug("insert into dataitems
successful");
}
catch
(SQLException Re ){ // Òì³£
log.error("insert into dataitems failed", Re);
Re.printStackTrace();
}
}
Ïà¹ØÎĵµ£º
×î¼òµ¥µÄSQL ServerÊý¾Ý¿â´æ´¢¹ý³Ì·ÖÒ³
·¢²¼Ê±¼ä£º2008.07.02 05:11 À´Ô´£ºÈüµÏÍø ×÷ÕߣºAlizze
¡¾ÈüµÏÍø£IT¼¼Êõ±¨µÀ¡¿×î¼òµ¥µÄSQL ServerÊý¾Ý¿â´æ´¢¹ý³Ì·ÖÒ³:
1.Ö»ÐèÒªÌṩSqlÓï¾äºÍÿҳµÄ¼Ç¼Êý,Ò³Êý¾Í¿ÉÒÔÁË
2,Ëٶȳ¬¿ìÓ´,100W¼Ç¼1~3Ãë¾Í·Ö³öÀ´ÁË
......
ÌâÄ¿£ºÓÐAºÍBÁ©¸ö±í£¬¶¼¶¨ÒåÏàͬµÄÖ÷¼ü£¬Ð´³öSQLÓï¾äÕÒ³öA±íÖÐÓжøB±íÖÐûÓеļǼ£¬È»ºó°ÑûÓеļǼ²åÈëµ½B±íÖС£
SQLÓï¾äÈçÏ£º
CREATE TABLE A_MINUS_B AS ---´´½¨Ò»¸ö²î¼¯±íA_MINUS_B ,×¢ÒâSELECT Óï¾äÒ»¶¨ÒªA±íÔÚÇ°¡ ......
1.ʹÓÃCÓïÑÔÀ´²Ù×÷SQL SERVERÊý¾Ý¿â,²ÉÓÃODBC¿ª·ÅʽÊý¾Ý¿âÁ¬½Ó½øÐÐÊý¾ÝµÄÌí¼Ó,ÐÞ¸Ä,ɾ³ý,²éѯµÈ²Ù×÷¡£
step1:Æô¶¯SQLSERVER·þÎñ,ÀýÈç:HNHJ,¿ªÊ¼²Ëµ¥ ->ÔËÐÐ ->net start mssqlserver
step2:´ò¿ªÆóÒµ¹ÜÀíÆ÷,½¨Á¢Êý¾Ý¿âtest,ÔÚtest¿âÖн¨Á¢test±í(a varchar(200),b varchar(200))
step3:½¨Á¢ÏµÍ³DSN,¿ªÊ¼²Ëµ ......
ÎÒÃÇÔÚ¹¤×÷ÖÐÏ£ÍûÄÜ¿´¼û×Ô¼ºÔËÐеÄDMLÓï¾äµÄÔËÐб¨¸æ£¬ÀýÈçselect,delete,update,megreºÍinsertÓï¾äÔËÐкóµÄÇé¿ö£¬ÒÔÓÃÀ´¼àÊӺ͵÷ÓÅÓï¾ä¡£ÎÒÃÇͨ³£ÔÚsql*plusÖÐʹÓÃset autotrace on¿ªÆô¡£
ÄÇautotraceÊÇÈçºÎ°²×°µÄÄØ£¿thomas kyteµÄ´ó×÷Öиø³öÁËÏêϸµÄ·½·¨ºÍ½âÊÍ£º
& ......
ÏÂÁÐÓï¾ä²¿·ÖÊÇMssqlÓï¾ä£¬²»¿ÉÒÔÔÚaccessÖÐʹÓá£
¡¡¡¡SQL·ÖÀࣺ
¡¡¡¡DDL—Êý¾Ý¶¨ÒåÓïÑÔ(CREATE£¬ALTER£¬DROP£¬DECLARE)
¡¡¡¡DML—Êý¾Ý²Ù×ÝÓïÑÔ(SELECT£¬DELETE£¬UPDATE£¬INSERT)
¡¡¡¡DCL—Êý¾Ý¿ØÖÆÓïÑÔ(GRANT£¬REVOKE£¬COMMIT£¬ROLLBACK)
¡¡¡¡Ê×ÏÈ,¼òÒª½éÉÜ»ù´¡Óï¾ä£º
¡¡¡¡1¡¢ËµÃ÷£º´´½¨Êý¾Ý¿â
......