導航:首頁 > 編程語言 > java使用sqlite

java使用sqlite

發布時間:2025-06-23 16:32:37

1. java連接sqlite3,怎麼支持中文路徑,路徑怎麼轉碼

importjava.sql.Connection;
importjava.sql.DriverManager;
importjava.sql.ResultSet;
importjava.sql.SQLException;
importjava.sql.Statement;

publicclassSample
{
publicstaticvoidmain(String[]args)
{
Connectionconnection=null;
try
{
//createadatabaseconnection
connection=DriverManager.getConnection("jdbc:sqlite:示例.db");
Statementstatement=connection.createStatement();
statement.setQueryTimeout(30);//settimeoutto30sec.

statement.executeUpdate("droptableifexistsperson");
statement.executeUpdate("createtableperson(idinteger,namestring)");
statement.executeUpdate("insertintopersonvalues(1,'leo')");
statement.executeUpdate("insertintopersonvalues(2,'yui')");
ResultSetrs=statement.executeQuery("select*fromperson");
while(rs.next())
{
//readtheresultset
System.out.println("name="+rs.getString("name"));
System.out.println("id="+rs.getInt("id"));
}
}
catch(SQLExceptione)
{
//iftheerrormessageis"outofmemory",
//
System.err.println(e.getMessage());
}
finally
{
try
{
if(connection!=null)
connection.close();
}
catch(SQLExceptione)
{
//connectionclosefailed.
System.err.println(e);
}
}
}
}

閱讀全文

與java使用sqlite相關的資料

熱點內容
子宮肌瘤手術前吃什麼解壓葯好 瀏覽:296
虛擬機兩台伺服器怎麼互聯 瀏覽:876
什麼是王者伺服器達到上限 瀏覽:574
linux伺服器地址看哪個 瀏覽:784
如何發送游戲鏈接伺服器 瀏覽:884
se殼網路驗證源碼下載 瀏覽:139
程序員的偶像都有誰 瀏覽:237
四川哪裡有考編程的學校 瀏覽:44
30源碼網會員 瀏覽:351
亮劍java項目開發案例導航源碼 瀏覽:829
四等測量前視距的演算法 瀏覽:909
java集合遍歷刪除 瀏覽:695
單片機的輸出驅動 瀏覽:922
zft屬於以太坊加密貨幣嗎 瀏覽:732
linuxexecve 瀏覽:978
java線程題目 瀏覽:169
倒角標注命令 瀏覽:745
防攻擊伺服器和國內有什麼區別 瀏覽:757
我的世界中國本地伺服器地址 瀏覽:993
周深參加密室大逃脫 瀏覽:612