[ת]JavaÁ¬½ÓSQLite dbÊý¾Ý¿âÎļþ
JavaÁ¬½ÓSQLiteÊý¾Ý¿âÏê½â ÏÂÔØSQLiteÊý¾Ý¿âµÄJDBC ÕâÀï¸ø³öÒ»¸öÖÐÎÄÕ¾µãµÄURL: ÉèÖû·¾³±äÁ¿£º ½«ÏÂÔص½µÄ°ü½âѹºóµÃµ½jar°ü sqlitejdbc-v033-nested.jar ·Åµ½%JAVA_HOME%\lib Ï£¬²¢ÇÒ½«ÆäÌí¼Óµ½classpathϵͳ»·¾³±äÁ¿ÖÐ,ÎÒµÄclasspathϵͳ»·¾³±äÁ¿ÏÖÔÚΪ: .;%JAVA_HOME%\lib;%JAVA_HOME%\lib\dt.jar;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\sqlitejdbc-v033-nested.jar
3 ÔÚÄãµÄ´úÂëÖÐÒýÓÃÕâ¸öÇý¶¯:
Class.forName("org.sqlite.JDBC");
Connection conn = DriverManager.getConnection("jdbc:sqlite:filename");//filenameΪÄãµÄSQLiteÊý¾ÝÃû³Æ
// ... use the database ...
conn.close();
ʾÀý³ÌÐòÈçÏ£º
import java.sql.*;
import org.sqlite.JDBC;
/**
* ÕâÊǸö·Ç³£¼òµ¥µÄSQLiteµÄJava³ÌÐò,
* ³ÌÐòÖд´½¨Êý¾Ý¿â¡¢´´½¨±í¡¢È»ºó²åÈëÊý¾Ý£¬
* ×îºó¶Á³öÊý¾ÝÏÔʾ³öÀ´
* @author zieckey (http://zieckey.cublog.cn)
*/
public class TestSQLite
{
public static void main(String[] args)
{
try
{
//Á¬½ÓSQLiteµÄJDBC
Class.forName("org.sqlite.JDBC");
//½¨Á¢Ò»¸öÊý¾Ý¿âÃûzieckey.dbµÄÁ¬½Ó£¬Èç¹û²»´æÔÚ¾ÍÔÚµ±Ç°Ä¿Â¼Ï´´½¨Ö®
Connection conn = DriverManager.getConnection("jdbc:sqlite:zieckey.db");
Statement stat = conn.createStatement();
stat.executeUpdate( "create table tbl1(name varchar(20), salary int);" );//´´½¨Ò»¸ö±í£¬Á½ÁÐ
stat.executeUpdate( "insert into tbl1 values('ZhangSan',8000);" ); //²åÈëÊý¾Ý
stat.executeUpdate( "insert into tbl1 values('LiSi',7800);" );
stat.executeUpdate( "insert into tbl1 values('WangWu',5800);" );
stat.executeUpdate( "insert into tbl1 values('ZhaoLiu',9100);" );
ResultSet rs = stat.executeQuery("select * from tbl1;"); //²éѯÊý¾Ý
while (rs.next()) { //½«²éѯµ½µÄÊý¾Ý´òÓ¡³öÀ´
System.out.print("name = " + rs.getString("name") + " "); //ÁÐÊôÐÔÒ»
System.out.println("salary = " + rs.getString("salary
Ïà¹ØÎĵµ£º
Ò»¸öʹÓÃÁ˶ÓÁеÄͨÓÃʵÏÖ£º
http://blog.csdn.net/chaosllgao/archive/2009/05/23/4211183.aspx
´ËÎÄÃèÊöÁËÒ»ÖÖ¸ü¼òµ¥µÄÄ£ÐÍ
1. ͬʱֻÓÐ1¸öÉú²úÕߺÍ1¸öÏû·ÑÕß
2. ²»ÓöÓÁУ¬Í¬Ê±Ö»ÓÐÒ»¸ö²úÆ·
3. Éú²úÕßÿ´ÎÉú²ú1¸ö0µ½100Ö®¼äµÄËæ»úÊý£¬Ïû·ÑÕßÔò°Ñ¸ÃËæ»úÊý´òÓ¡³öÀ´¡£Èç¹û²úÉúµÄËæ»úÊýΪ0£¬Ôò ......
ÓÐÈË·´Ó³¿´²»µ½Ô´Â룬·¢ÏÖÊÇCSDNµÄ´úÂë¿Ø¼þÓÐÎÊÌ⡣ϣÍûCSDNºÃºÃ¸Ä½øһϡ£
ÔÝʱÏÈÒÔÎı¾·½Ê½·¢²¼³öÀ´£¬¸ñʽ»á±äÑù¡£
import java.util.LinkedList;
public class ProducerConsumer
{
/**
* @param args
*/
public static void main(String[] args)
{
Queue queue = ......
finalize·½·¨
ËüÊÇjava.lang.ObjectÀàÖеķ½·¨. ÊÇprotectedµÄ.
ȱʡʱÕâ¸ö·½·¨ÊÇ¿ÕµÄ. JavaÔËÐÐϵͳÔÚÀ¬»ø»ØÊÕʱÔÚ¶ÔÏó±»³·Ïú֮ǰµ÷ÓÃÕâ¸ö·½·¨. µ«ÓÉÓÚÀ¬»øµ¥Ôª
»ØÊÕµÄʱ¼äÊDz»È·¶¨µÄ.ËùÒÔ²»Äܹý·ÖÒÀÀµËü(ÕâºÍc++µÄÎö¹¹º¯Êý²»Í¬).
¶øÖ»ÄÜÊÇ"ÔÚ¶ÔÏó±»³·Ïú֮ǰ"×öһЩ´¦Àí.ÀýÈç¿ÉÒÔÔÚÕâÀï¹Ø±Õ¹¹Ôì·½·¨Öдò¿ ......
JAVAרҵÊõÓO
API£ºJava ApplicationProgrammingInterface API£¨Ó¦ÓóÌÐò½Ó¿Ú£©ÊÇÊÂÏÈдºÃµÄ´úÂë,
×éÖ¯µ½Ïà¹Ø°ü¡£ÀýÈç Applet ºÍ AWT °ü°üÀ¨½¨Á¢×ÖÌå¡¢²Ëµ¥¡¢°´Å¥µÄÀࣨCLASS£©£¬
È«²¿µÄJava API±»°üº¬ÔÚJavaTM 2 Stan ......
³ö´¦£ºÀ´Ô´ÓÚCSDN ZangXT´óϺ¶Ôijƪ¹ØÓÚjavaÖÐÕ»Óë¶ÑµÄÎÄÕµĻظ´
´óÌå·ÖÎöÒ»ÏÂ
1. Õ»(stack)Óë¶Ñ(heap)¶¼ÊÇJavaÓÃÀ´ÔÚRamÖдæ·ÅÊý¾ÝµÄµØ·½¡£ÓëC++²»Í¬£¬Java×Ô¶¯¹ÜÀíÕ»ºÍ¶Ñ£¬³ÌÐòÔ±²»ÄÜÖ±½ÓµØÉèÖÃÕ»»ò¶Ñ¡£
//Õ»¶¼ÊÇÓÉÔËÐл·¾³À´´¦ÀíµÄ£¬Õâµã£Ã£«£«ºÍ£ê£á£ö£áûÓÐʲô²»Í¬£®¶ÔÓڶѣ¬²»¹ý£ê£á£ö£á¶àÁ˸ö£Ç£Ã£®
2.͉˕ ......