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

Java 6 ÖÐ×Ô´øµÄ Java DB(derby) Êý¾Ý¿â

а²×°ÁË JDK 6 µÄ³ÌÐòÔ±ÃÇÒ²Ðí»á·¢ÏÖ£¬³ýÁË´«Í³µÄ bin¡¢jre µÈĿ¼£¬JDK 6 ÐÂÔöÁËÒ»¸öÃûΪ db µÄĿ¼¡£Õâ±ãÊÇ Java 6 µÄгÉÔ±£ºJava DB¡£ÕâÊÇÒ»¸ö´¿ Java ʵÏÖ¡¢¿ªÔ´µÄÊý¾Ý¿â¹ÜÀíϵͳ£¨DBMS£©£¬Ô´ÓÚ Apache Èí¼þ»ù½ð»á£¨ASF£©ÃûϵÄÏîÄ¿ Derby¡£ËüÖ»ÓÐ 2MB ´óС£¬¶Ô±È¶¯éüÉÏ G µÄÊý¾Ý¿âÀ´Ëµ¿ÉνÐäÕä¡£µ«Õâ²¢²»·Á°­ Derby ¹¦ÄÜÆ뱸£¬Ö§³Ö¼¸ºõ´ó²¿·ÖµÄÊý¾Ý¿âÓ¦ÓÃËùÐèÒªµÄÌØÐÔ¡£¸üÄÑÄܿɹóµÄÊÇ£¬ÒÀÍÐÓÚ ASF Ç¿´óµÄÉçÇøÁ¦Á¿£¬Derby µÃµ½ÁË°üÀ¨ IBM ºÍ Sun µÈ´ó¹«Ë¾ÒÔ¼°È«ÊÀ½çÓÅÐã³ÌÐòÔ±ÃǵÄÖ§³Ö¡£ÕâÒ²ÄÑ¹Ö Sun ¹«Ë¾»áÑ¡ÔñÆä 10.2.2 °æ±¾ÄÉÈëµ½ JDK 6 ÖУ¬×÷ΪÄÚǶµÄÊý¾Ý¿â¡£Õâ¾ÍºÃÏñΪ JDK ×¢ÈëÁËÒ»¹ÉȫеĻîÁ¦£ºJava ³ÌÐòÔ±²»ÔÙÐèÒªºÄ·Ñ´óÁ¿¾«Á¦°²×°ºÍÅäÖÃÊý¾Ý¿â£¬¾ÍÄܽøÐа²È«¡¢Ò×Óᢱê×¼¡¢²¢ÇÒÃâ·ÑµÄÊý¾Ý¿â±à³Ì¡£ÔÚÕâÒ»ÕÂÖУ¬ÎÒÃǽ«³õ¿ú Java DB µÄÊÀ½ç£¬À´Ì½¾¿ÈçºÎʹÓÃËü±àд³ö¹¦ÄܷḻµÄ³ÌÐò¡£
1~&ex r4f^ B NuJt0Hello, Java DB£ºÄÚǶģʽµÄ Derby
2[E(`+}JS3|sE0¼ÈÈ»ÓÐÁËÄÚǶ£¨embedded£©µÄÊý¾Ý¿â£¬¾ÍÈÃÎÒÃÇ´ÓÒ»¸ö¼òµ¥µÄ·¶Àý¿ªÊ¼£¬ÊÔ×ÅʹÓÃËü°É¡£Õâ¸ö³ÌÐò×öÁË´ó¶àÊýÊý¾Ý¿âÓ¦Óö¼¿ÉÄÜ»á×öµÄ²Ù×÷£ºÔÚ DBMS Öд´½¨ÁËÒ»¸öÃûΪ helloDB µÄÊý¾Ý¿â£»´´½¨ÁËÒ»ÕÅÊý¾Ý±í£¬È¡ÃûΪ hellotable£»Ïò±íÄÚ²åÈëÁËÁ½ÌõÊý¾Ý£»È»ºó£¬²éѯÊý¾Ý²¢½«½á¹û´òÓ¡ÔÚ¿ØÖÆ̨ÉÏ£»×îºó£¬É¾³ý±íºÍÊý¾Ý¿â£¬ÊÍ·Å×ÊÔ´¡£
$J,D6T9\ b,g0public class HelloJavaDB {
:\xB f-v e[,K0public static void main(String[] args) { ÖÐÎÄJAVA¼¼ÊõÍø0A r&^9b S s'E)x
try { // load the driver
5vF1i] u3yU%t+xW.?0Class.forName("org.apache.derby.jdbc.EmbeddedDriver").newInstance();
Ei.[0MbJ0System.out.println("Load the embedded driver");
@v/YhRo#l0Connection conn = null; ÖÐÎÄJAVA¼¼ÊõÍø1t|O7r$`WOT
Properties props = new Properties(); ÖÐÎÄJAVA¼¼ÊõÍø(D#i8}YgW%]u
props.put("user", "user1"); props.put("password", "user1"); ÖÐÎÄJAVA¼¼ÊõÍø-q:d9@P"F4E9wa R
//create and connect the database named helloDB ÖÐÎÄJAVA¼¼ÊõÍø1]T^OT-{Nu3o w
conn=DriverManager.getConnection("jdbc:derby:helloDB;create=true", props); ÖÐÎÄJAVA¼¼ÊõÍøakm1k4? y
System.out.println("create and connect to helloDB"); ÖÐÎÄJAVA¼¼ÊõÍø6|f__ ];O
conn.setAutoCommit(false); ÖÐÎÄJAVA¼¼ÊõÍøX;K?Cm3@;D7


Ïà¹ØÎĵµ£º

ÿһ¸öJAVA³õѧÕ߶¼Ó¦¸Ã¸ã¶®µÄÎÊÌâ

¡¡¶ÔÓÚÕâ¸öϵÁÐÀïµÄÎÊÌ⣬ÿ¸öѧJavaµÄÈ˶¼Ó¦¸Ã¸ã¶®¡£µ±È»£¬Èç¹ûÖ»ÊÇѧJavaÍæÍæ¾ÍÎÞËùνÁË¡£Èç¹ûÄãÈÏΪ×Ô¼ºÒѾ­³¬Ô½³õѧÕßÁË£¬È´²»ºÜ¶®ÕâЩÎÊÌ⣬Ç뽫Äã×Ô¼ºÖعé³õѧÕßÐÐÁС£ÄÚÈݾùÀ´×ÔÓÚCSDNµÄ¾­µäÀÏÌù¡£
¡¡¡¡ÎÊÌâÒ»£ºÎÒÉùÃ÷ÁËʲô£¡
¡¡¡¡String s = "Hello world!";
¡¡¡¡Ðí¶àÈ˶¼×ö¹ýÕâÑùµÄÊÂÇ飬µ«ÊÇ£¬ÎÒÃǵ½µ×Éùà ......

TriÊ÷£¨×ÖµäÊ÷JAVA°æ£©ÁªÏëÊäÈë·¨ËùÓõÄÊý¾Ý½á¹¹

ÓÖµ½Á˿츴ÊÔµÄʱºòÁË¡£Ò£ÏëÈ¥Äê´Ëʱ£¬ÐÄÇéìþìý²»°²£¬¸´ÊÔ»úÊÔ²îµã¹Òµô¡£µ±Ê±¿¼µÄÊÇ£¬ÁªÏëÊäÈë·¨£¬ÏëÏ붼¿Ö²À¡£Õâ¶Îʱ¼äдËã·¨£¬Ë³±ã°ÑÄǸö¸øдÁË¡£Ò²Ëã×îºó¼ÍÄîÒ»ÏÂÎҵĿ¼ÑС£ÎÒ°®ÐÂѧУ£¬ÎÒÒ²°®ÎÒµÄͬѧºÍÀÏʦ£¬ÎÒºÜÕäϧÕâ´Î½øÈëÑо¿ÉúÔºµÄ»ú»á¡£Ò²Ï£ÍûÄÇЩ´ËʱºÍÎÒµ±Ê±Ò»Ñùìþìý²»°²µÄ¿¼Éú¿ÉÒÔʵÏÖÃÎÏ룡£¡
import java. ......

dz̸Java¶àÏ̵߳Äͬ²½ÎÊÌâ

¶àÏ̵߳Äͬ²½ÒÀ¿¿µÄÊǶÔÏóËø»úÖÆ£¬synchronized¹Ø¼ü×ֵı³ºó¾ÍÊÇÀûÓÃÁË·âËøÀ´ÊµÏÖ¶Ô¹²Ïí×ÊÔ´µÄ»¥³â·ÃÎÊ¡£
ÏÂÃæÒÔÒ»¸ö¼òµ¥µÄʵÀýÀ´½øÐжԱȷÖÎö¡£ÊµÀýÒªÍê³ÉµÄ¹¤×÷·Ç³£¼òµ¥£¬¾ÍÊÇ´´½¨10¸öỊ̈߳¬Ã¿¸öÏ̶߳¼´òÓ¡´Ó0µ½99Õâ100¸öÊý×Ö£¬ÎÒÃÇÏ£ÍûÏß³ÌÖ®¼ä²»»á³öÏÖ½»²æÂÒÐò´òÓ¡£¬¶øÊÇ˳ÐòµØ´òÓ¡¡£
ÏÈÀ´¿´µÚÒ»¶Î´úÂ룬ÕâÀïÎÒÃÇÔÚru ......

Java DB ºÍ JDBC 4.0

http://developers.sun.com/javadb/
Java SE 6 ÐÂÌØÐÔ: Java DB ºÍ JDBC 4.0
http://www.ibm.com/developerworks/cn/java/j-lo-jse65/
³¤¾ÃÒÔÀ´£¬ÓÉÓÚ´óÁ¿£¨ÉõÖÁ¼¸ºõËùÓУ©µÄ Java Ó¦Óö¼ÒÀÀµÓÚÊý¾Ý¿â£¬ÈçºÎʹÓà Java ÓïÑÔ¸ßЧ¡¢¿É¿¿¡¢¼ò½àµØ·ÃÎÊÊý¾Ý¿âÒ»Ö±ÊdzÌÐòÔ±Ãǽò½òÀÖµÀµÄ»°Ì⡣з¢²¼µÄ Java SE 6 Ò²ÔÚÕâ·½Ãæ¸üÉ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ