IntellJIdea2020版怎么添加sqlite數(shù)據(jù)庫-創(chuàng)新互聯(lián)

本篇內(nèi)容介紹了“IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫”的有關(guān)知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!

成都創(chuàng)新互聯(lián)公司10多年企業(yè)網(wǎng)站設(shè)計服務(wù);為您提供網(wǎng)站建設(shè),網(wǎng)站制作,網(wǎng)頁設(shè)計及高端網(wǎng)站定制服務(wù),企業(yè)網(wǎng)站設(shè)計及推廣,對成都葡萄架等多個方面擁有多年的網(wǎng)站維護經(jīng)驗的網(wǎng)站建設(shè)公司。

工具列表:

1.Sqlite

2. SQLiteStudio

3. IntellJ

4. sqlite-jdbc-3.32.3.2.jar

運行結(jié)果先睹為快:

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

下載安裝IntellJ

直接到官網(wǎng)下載即可,新手建議不要下載新的,一旦編譯器UI上有修改和教程對不上號,自己爬樓摸索比較話時間。當(dāng)然也會有第一手的寶貴收獲。

https://www.jetbrains.com/idea/download/#section=windows

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

下載Sqlite開發(fā)工具

https://www.sqlite.org/download.html

解壓后直接可以運行,無需安裝。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

創(chuàng)建數(shù)據(jù)庫文件

創(chuàng)建studio.sqlite名稱的數(shù)據(jù)庫文件。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

注釋:如果出現(xiàn)無法生成的現(xiàn)象,在“sqlite>”后輸入任意非空字符后回車然后Ctrl+C取消即可生成studio.sqlite文件。(.sqlite,.db后綴數(shù)據(jù)庫文件均可識別。)

此處如果只創(chuàng)建一個空白的文件,也可以用修改后綴的方法直接新建一個*.db文件。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

數(shù)據(jù)庫文件寫入數(shù)據(jù)

這個網(wǎng)絡(luò)地址可以下載SQLiteStudio,還有使用教程??梢苑奖愕匿浫霐?shù)據(jù)。

http://www.xue51.com/soft/4831.html

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

數(shù)據(jù)庫錄入數(shù)據(jù)

錄入示例數(shù)據(jù)和字段完成如下所示:

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

進(jìn)入IntellJ配置數(shù)據(jù)庫

此時發(fā)現(xiàn)Tool Windows中沒有Database選項,需要安裝Database工具包。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

File-》Settings-》Plugins

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

選擇Plugins,搜索框搜索database,安裝“Database Navigator”,然后重啟Intellj應(yīng)用。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

重啟后,左邊框會出現(xiàn)“DB Browser”選項。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

java代碼如下:

import java.sql.*;
 
public class database {
  public static void main(String[] arg) throws ClassNotFoundException, SQLException {
    System.out.println("database");
    Connection conn = null;
    ResultSet rs = null;
    Statement statement;
    Class.forName("org.sqlite.JDBC");//sqlite database name.
    conn = DriverManager.getConnection("jdbc:sqlite:F:\\codeZ\\database\\mysqlite1.sqlite");
    statement = conn.createStatement();
    rs = statement.executeQuery("SELECT * FROM demo"); //this is name of database list
    while (rs.next()){
      System.out.println("--------------------");
      System.out.print("id:"+rs.getString("id"));
      System.out.print("  name:"+rs.getString("name"));
      System.out.println("  age:"+rs.getString("age"));
    }
 
  }
}

注意:

1. 數(shù)據(jù)庫操作函數(shù)中存在異常,因此需要包含ClassNotFoundException, SQLException,參考編譯器調(diào)試添加即可。

運行結(jié)果如下所示:

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

附錄:

問題一:數(shù)據(jù)庫加載失敗

出現(xiàn)如下錯誤,可能是沒有添加jar包導(dǎo)致。sqlite-jdbc-3.32.3.2.jar

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

file-》Project structure-》

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

添加sqlite-jdbc-3.32.3.2.jar,記得勾選。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

問題二:

如下URL對應(yīng)的就是數(shù)據(jù)庫的路徑和名稱。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

問題三:無法連接數(shù)據(jù)庫

查看數(shù)據(jù)庫url名稱,并且運行代碼之前確保數(shù)據(jù)庫是disconnect狀態(tài)。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

題四:讀取表信息失敗

如下為數(shù)據(jù)庫創(chuàng)建的表名字不對應(yīng),使用SQLiteStudio打開數(shù)據(jù)庫文件查看DLL(參考上面的圖)修改為正確的名稱即可。

IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫

“IntellJ Idea 2020版怎么添加sqlite數(shù)據(jù)庫”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實用文章!

網(wǎng)頁名稱:IntellJIdea2020版怎么添加sqlite數(shù)據(jù)庫-創(chuàng)新互聯(lián)
網(wǎng)頁鏈接:http://muchs.cn/article18/eipgp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供商城網(wǎng)站、面包屑導(dǎo)航、網(wǎng)站改版、網(wǎng)站維護、手機網(wǎng)站建設(shè)、企業(yè)建站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化