java statement×÷ÓÃ
1¡¢´´½¨ Statement ¶ÔÏó
½¨Á¢Á˵½Ìض¨Êý¾Ý¿âµÄÁ¬½ÓÖ®ºó£¬¾Í¿ÉÓøÃÁ¬½Ó·¢ËÍ SQL Óï¾ä¡£Statement ¶ÔÏóÓà Connection µÄ·½·¨ createStatement ´´½¨£¬ÈçÏÂÁдúÂë¶ÎÖÐËùʾ£º
Connection con = DriverManager.getConnection(url, "sunny", "");
Statement stmt = con.createStatement();
ΪÁËÖ´ÐÐ Statement ¶ÔÏ󣬱»·¢Ë͵½Êý¾Ý¿âµÄ SQL Óï¾ä½«±»×÷Ϊ²ÎÊýÌṩ¸ø Statement µÄ·½·¨£º
ResultSet rs = stmt.executeQuery("SELECT a, b, c from Table2");
2¡¢Ê¹Óà Statement ¶ÔÏóÖ´ÐÐÓï¾ä
Statement ½Ó¿ÚÌṩÁËÈýÖÖÖ´ÐÐ SQL Óï¾äµÄ·½·¨£ºexecuteQuery¡¢executeUpdate ºÍ execute¡£Ê¹ÓÃÄÄÒ»¸ö·½·¨ÓÉ SQL Óï¾äËù²úÉúµÄÄÚÈݾö¶¨¡£
·½·¨ executeQuery ÓÃÓÚ²úÉúµ¥¸ö½á¹û¼¯µÄÓï¾ä£¬ÀýÈç SELECT Óï¾ä¡£
·½·¨ executeUpdate ÓÃÓÚÖ´ÐÐ INSERT¡¢UPDATE »ò DELETE Óï¾äÒÔ¼° SQL DDL£¨Êý¾Ý¶¨ÒåÓïÑÔ£©Óï¾ä£¬ÀýÈç CREATE TABLE ºÍ DROP TABLE¡£INSERT¡¢UPDATE »ò DELETE Óï¾äµÄЧ¹ûÊÇÐ޸ıíÖÐÁãÐлò¶àÐÐÖеÄÒ»Áлò¶àÁС£executeUpdate µÄ·µ»ØÖµÊÇÒ»¸öÕûÊý£¬Ö¸Ê¾ÊÜÓ°ÏìµÄÐÐÊý£¨¼´¸üмÆÊý£©¡£¶ÔÓÚ CREATE TABLE »ò DROP TABLE µÈ²»²Ù×÷ÐеÄÓï¾ä£¬executeUpdate µÄ·µ»ØÖµ×ÜΪÁã¡£
·½·¨ execute ÓÃÓÚÖ´Ðзµ»Ø¶à¸ö½á¹û¼¯¡¢¶à¸ö¸üмÆÊý»ò¶þÕß×éºÏµÄÓï¾ä¡£ÒòΪ¶àÊý³ÌÐòÔ±²»»áÐèÒª¸Ã¸ß¼¶¹¦ÄÜ£¬ËùÒÔ±¾¸ÅÊöºóÃ潫ÔÚµ¥¶ÀÒ»½ÚÖжÔÆä½øÐнéÉÜ¡£
Ö´ÐÐÓï¾äµÄËùÓз½·¨¶¼½«¹Ø±ÕËùµ÷ÓÃµÄ Statement ¶ÔÏóµÄµ±Ç°´ò¿ª½á¹û¼¯£¨Èç¹û´æÔÚ£©¡£ÕâÒâζ×ÅÔÚÖØÐÂÖ´ÐÐ Statement ¶ÔÏó֮ǰ£¬ÐèÒªÍê³É¶Ôµ±Ç° ResultSet ¶ÔÏóµÄ´¦Àí¡£
ӦעÒ⣬¼Ì³ÐÁË Statement ½Ó¿ÚÖÐËùÓз½·¨µÄ PreparedStatement ½Ó¿Ú¶¼ÓÐ×Ô¼ºµÄ executeQuery¡¢executeUpdate ºÍ execute ·½·¨¡£Statement ¶ÔÏó±¾Éí²»°üº¬ SQL Óï¾ä£¬Òò¶ø±ØÐë¸ø Statement.execute ·½·¨Ìṩ SQL Óï¾ä×÷Ϊ²ÎÊý¡£PreparedStatement ¶ÔÏó²¢²»½« SQL Óï¾ä×÷Ϊ²ÎÊýÌṩ¸øÕâЩ·½·¨£¬ÒòΪËüÃÇÒѾ°üº¬Ô¤±àÒë SQL Óï¾ä¡£CallableStatement ¶ÔÏó¼Ì³ÐÕâЩ·½·¨µÄ PreparedStatement ÐÎʽ¡£¶ÔÓÚÕâЩ·½·¨µÄ PreparedStatement »ò CallableStatement °æ±¾£¬Ê¹Óòéѯ²ÎÊý½«Å׳ö SQLException¡£
3¡¢Óï¾äÍê³É
µ±Á¬½Ó´¦ÓÚ×Ô¶¯Ìύģʽʱ£¬ÆäÖÐËùÖ´ÐеÄÓï¾äÔÚÍê³Éʱ½«×Ô¶¯Ìá½»»ò»¹Ô¡£Óï¾äÔÚÒÑÖ´ÐÐÇÒËùÓнá¹û·µ»Øʱ£¬¼´ÈÏΪÒÑÍê³É¡£¶ÔÓÚ·µ»ØÒ»¸ö½á¹û¼¯µÄ executeQuery ·½·¨£¬ÔÚ¼ìË÷Íê ResultSet ¶ÔÏóµÄËùÓÐÐÐʱ¸ÃÓï¾äÍê³É¡£¶ÔÓÚ·½·¨ executeUpdate
Ïà¹ØÎĵµ£º
Ò» ÎÊÌâµÄÌá³ö
JavaµÄÒ»¸öÖØÒªÓŵã¾ÍÊÇͨ¹ýÀ¬»øÊÕ¼¯Æ÷(Garbage Collection£¬GC)×Ô¶¯¹ÜÀíÄÚ´æµÄ»ØÊÕ£¬³ÌÐòÔ±²»ÐèҪͨ¹ýµ÷Óú¯ÊýÀ´ÊÍ·ÅÄÚ´æ¡£Òò´Ë£¬ºÜ¶à³ÌÐòÔ±ÈÏΪJava²»´æÔÚÄÚ´æй©ÎÊÌ⣬»òÕßÈÏΪ¼´Ê¹ ÓÐÄÚ´æй©Ҳ²»ÊdzÌÐòµÄÔðÈΣ¬¶øÊÇGC»òJVMµÄÎÊÌâ¡£Æäʵ£¬ÕâÖÖÏë·¨ÊDz»ÕýÈ·µÄ£¬Òò ......
ÔÚÎÒ»úÆ÷ÉÏ°²×°µÄÊÇJDK6£¬ÏÂÔØactiveMQ5.3Æô¶¯Ê±±¨´í£¬Ìáʾjaxb°üÒѾ¼ÓÔØ2.0°æ±¾ÎÞ·¨¼ÓÔØ2.1°æ±¾¡£
ÎÒͨ¹ýÍøÂçËÑË÷ÁËһϷ¢ÏÖ£¬jaxb2.0ÊÇJDK·¢²¼Ê±°üº¬ÔÚrt.jar°üÖеġ£µ«ÊÇactiveMQ5.3È´ÐèÒª2.1°æ±¾¡£Õâ¸ÃÈçºÎ´¦Àí£¿
×ܲ»Äܽ«rt.jar°ü½â¿ª£¬½«jaxb2.1µÄÀา¸Ç½øÈ¥£¬ÔÙÖØдò°ü°É¡£ÕâÑùÌ«Âé·³ÁË¡£
ÔٴνøÐÐÍøÂçËÑË÷£¬·¢ ......
Õû¸öÀàÎļþ×¢ÊÍ
ʾÀýÈçÏÂ
:
/*
* @(#)Object.java
1.61 03/01/23
*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package java.lang;
& ......
±¾ÎÄת×Ô£ºhttp://cyp-034.blog.163.com/blog/static/2823190520074691849380/
stream
´ú±íµÄÊÇÈκÎÓÐÄÜÁ¦²ú³öÊý¾ÝµÄÊý¾ÝÔ´£¬»òÊÇÈκÎÓÐÄÜÁ¦½ÓÊÕÊý¾ÝµÄ½ÓÊÕÔ´¡£ÔÚJavaµÄIOÖУ¬ËùÓеÄstream£¨°üÀ¨InputstreamºÍ
Out stream£©¶¼°üÀ¨Á½ÖÖÀàÐÍ£º
(1)×Ö½ÚÁ÷
±íʾÒÔ×Ö½ÚΪµ¥Î»´ÓstreamÖжÁÈ¡»òÍùstreamÖÐдÈë ......
Java×ÜÓÐËüµÄǧ°ãºÃ´¦Ê¹ÄãÑ¡ÔñËü£¬µ«ÕâЩËæ±ã··Êé»òÔÚÍøÉϹäһȦ¾ÍÄÜÕÒµ½´ð°¸¡£ÔÚ±¾ÎÄÖУ¬±ÊÕß°Ñ×Ô¼ºÑ§Ï°JavaµÄһЩÇÐÉíÌå»áºÍ¹ý³Ìд³öÀ´£¬¹©³õѧÕß×ö¸ö²Î¿¼¡£
http://school.itzcn.com/special-spid-50.html
¡¡¡¡ÎÒÔÚѧϰJavaµÄ¹ý³ÌÖÐÖ÷ҪΧÈÆÒÔϼ¸¸ö·½ÃæÀ´Ñ§Ï°£º
¡¡¡¡1.ʱ¿ÌÌáÐÑ×Ô¼ºJavaÊÇÒ»ÖÖOOPÓïÑÔ¹¤¾ß£¬¶ø²»½ö½ ......