目前日期文章:200807 (3)

瀏覽方式: 標題列表 簡短摘要

give 發表在 痞客邦 留言(0) 人氣()

Step0. 安裝Python
首先, 要先安裝Python(當然....)


Step1. 安裝easy_install
下載ez_setup.py, 並安裝, 參考
http://peak.telecommunity.com/DevCenter/EasyInstall#installing-easy-install


Step2. 下載TurboGears並安裝
C:easy_install TurboGears
(參考: http://www.ibm.com/developerworks/cn/linux/l-turbogears/index.html )

若無法執行easy_install, 檢查一下系統PATH變數
On Windows, an easy_install.exe launcher will also be installed, so that you can just type easy_install as long as it's on your PATH. If typing easy_install at the command prompt doesn't work, check to make sure your PATH includes the appropriate C:\Python2X\Scripts directory.


Step3: 執行tg-admin
C:>tg-admin

TurboGears 1.0.5 command line interface

Usage: C:Python25Scriptstg-admin-script.py [options]

Options:
-c CONFIG --config=CONFIG Config file to use
-e EGG_SPEC --egg=EGG_SPEC Run command on given Egg

Commands:
i18n Manage i18n data
info Show version info
quickstart Create a new TurboGears project
shell Start a Python prompt with your database available
sql Run the database provider manager
toolbox Launch the TurboGears Toolbox
update Update an existing turbogears project

give 發表在 痞客邦 留言(0) 人氣()

文章取自Eclipse上的wiki
http://wiki.eclipse.org/index.php/Connecting_to_SQLite

節錄如下

1) Download the SQLite drivers from: [1]. The actual zip file with the driver is at [2]. Expand the zip somewhere locally and note the location.


2) Put the sqlite_jni.dll from the zip into your JRE's bin directory. The driver requires this file to be in the java library path.


3) In Eclipse with DTP 1.0 installed (preferably the final build or a nightly build dated 110806 or later), go to the Preferences (Window->Preferences) and select the Connectivity->Driver Definitions page.


4) Select the "Generic JDBC" category in the Available Driver Definitions tree and click "Add...".


5) Select "Generic JDBC Driver->Generic JDBC Driver" in the Available Driver Templates tree. Give the new generic JDBC driver a name like "javasqlite JDBC driver". Click OK.


6) Click "Add Jar/Zip" and select the sqlite.jar from the driver zip you expanded in step 1. Click Open.


7) In the Properties table, select the Driver Class property and click the "..." button. If the jar is accessible, you will see a dialog appear with at lease one class in the list. Select "SQLite.JDBCDriver". Click OK.


8) Also in the Properties table, select the Driver URL property and type the following: jdbc:sqlite:/DRIVE:/dirA/dirB/dbfile


9) Click OK on the Edit Driver Definition dialog. You should see your new driver appear in the driver list on the Driver Definitions preference page.


10) Click OK to close the Preferences dialog.


11) If the Data Source Explorer is not open, open the Connectivity->Data Source Explorer view from the Window->Show View menu or open the Database Development perspective from the Window->Open Perspective.


12) In the Data Source Explorer, right-click on the Databases category and select New...


13) In the New Connection Profile wizard's Wizard Selection Page, choose the SQL Model-JDBC Connection entry in the list and click Next.


14) Give your new profile a name like "SQLiteTestDB". Click Next.


15) In the "Select a driver from the drop-down" combo box, select your new SQLite driver definition. Modify the file path in the sample URL to match the path to your local SQLite database.


16) Click "Test Connection" to verify you can connect to your database.


17) Click Finish to create the profile.


18) In the Data Source Explorer, right-click on the new profile and select Connect. You should see content appear in the tree beneath the profile. Browse through your database to view available tables and their columns.


JDBC Driver載點
http://www.ch-werner.de/javasqlite/javasqlite-20080420-win32.zip

Code snippet:
Connection conn = null;
SQLite.Database db = null;
try {
Class.forName("SQLite.JDBCDriver").newInstance();
conn = DriverManager.getConnection("jdbc:sqlite:/blabla");
java.lang.reflect.Method m =
conn.getClass().getMethod("getSQLiteDatabase", null);
db = (SQLite.Database) m.invoke(conn, null);
} catch (Exception e) {

}

在Netbeans中設定Connection
  1. 先在Global Library中建立SQLite的項目
  2. 在Project中引入這個Library
  3. 在Netbeans中移到Services頁籤,建立一個新的JDBC Driver profile
  4. 然後建立一個Connection,選擇剛剛建立的profile,Database URL的設定如下
  5. 完工,驗證一下




give 發表在 痞客邦 留言(0) 人氣()