[ת]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
Ïà¹ØÎĵµ£º
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......
import lotus.domino.*;
import java.io.*;
import java.util.Vector;
import jxl.*;
/*******************************************************************************
* @saveSQMessageToOracle
* @×÷ÕߣºÐ컪Ïé
* @2009Äê10ÔÂ28ÈÕ
* @˵Ã÷£ºExeclÎļþµÄµ¼Èë
********** ......
ÓÐÈË·´Ó³¿´²»µ½Ô´Â룬·¢ÏÖÊÇCSDNµÄ´úÂë¿Ø¼þÓÐÎÊÌ⡣ϣÍûCSDNºÃºÃ¸Ä½øһϡ£
ÔÝʱÏÈÒÔÎı¾·½Ê½·¢²¼³öÀ´£¬¸ñʽ»á±äÑù¡£
import java.util.LinkedList;
public class ProducerConsumer
{
/**
* @param args
*/
public static void main(String[] args)
{
Queue queue = ......
String Óë StringBufferÇø±ð:
String×Ö·û´®¶ÔÏóÊDz»¿É±äµÄ£»StringBufferÊDZ䳤ºÍ¿ÉдµÄ¶¯Ì¬×Ö·ûÐòÁУ¬¿ÉÒÔ×Ô¶¯µØÔö¼Ó¿Õ¼ä¡£
Integer var = new Integer();//ÓÐÓï·¨´íÎó
Integer var = new Integer(2);//悦﵀
javaµÄVector³ÉÔ±ÊÇÒªÓÃelementAt(i)³ÉÔ±º¯ÊýÀ´»ñµÃµÄ£¬²»ÄÜÓÃve[i]µÃµ½¡£
Vector::public Enumeration& ......
finalize·½·¨
ËüÊÇjava.lang.ObjectÀàÖеķ½·¨. ÊÇprotectedµÄ.
ȱʡʱÕâ¸ö·½·¨ÊÇ¿ÕµÄ. JavaÔËÐÐϵͳÔÚÀ¬»ø»ØÊÕʱÔÚ¶ÔÏó±»³·Ïú֮ǰµ÷ÓÃÕâ¸ö·½·¨. µ«ÓÉÓÚÀ¬»øµ¥Ôª
»ØÊÕµÄʱ¼äÊDz»È·¶¨µÄ.ËùÒÔ²»Äܹý·ÖÒÀÀµËü(ÕâºÍc++µÄÎö¹¹º¯Êý²»Í¬).
¶øÖ»ÄÜÊÇ"ÔÚ¶ÔÏó±»³·Ïú֮ǰ"×öһЩ´¦Àí.ÀýÈç¿ÉÒÔÔÚÕâÀï¹Ø±Õ¹¹Ôì·½·¨Öдò¿ ......