久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

IntellJ Idea 2020版添加sqlite數(shù)據(jù)庫的方法

瀏覽:130日期:2024-08-04 17:42:57

工具列表:

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ù)庫的方法

進入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:codeZdatabasemysqlite1.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ù)庫的方法

到此這篇關(guān)于IntellJ Idea 2020版添加sqlite數(shù)據(jù)庫的方法的文章就介紹到這了,更多相關(guān)Idea添加sqlite數(shù)據(jù)庫內(nèi)容請搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標簽: IDEA
相關(guān)文章:
主站蜘蛛池模板: 玉山县| 浦北县| 长宁区| 上饶市| 南陵县| 广安市| 兴国县| 牙克石市| 楚雄市| 岳池县| 余江县| 永济市| 花莲市| 牙克石市| 陕西省| 罗山县| 大厂| 吉林市| 云梦县| 汽车| 连江县| 武功县| 无极县| 姜堰市| 万州区| 南开区| 汝州市| 青龙| 土默特左旗| 江安县| 宁远县| 博白县| 阆中市| 湘阴县| 许昌市| 敦化市| 海伦市| 黄大仙区| 邯郸县| 铜梁县| 潜山县|