導航:首頁 > 編程語言 > 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相關的資料

熱點內容
解壓香皂切割視頻大全 瀏覽:974
pdf越南 瀏覽:281
蘋果app商店搜索不到微信怎麼辦 瀏覽:986
程序通過編譯是什麼意思 瀏覽:26
學會時間管理對緩解壓力重要嗎 瀏覽:509
android業務邏輯層 瀏覽:826
sdk打開文件夾 瀏覽:258
伊朗北面命令世界大耳朵圖圖 瀏覽:561
javastring比較大小 瀏覽:561
機房伺服器和雲伺服器對比 瀏覽:955
程序員三部曲教學 瀏覽:494
方舟編譯器准備就緒 瀏覽:463
學習單片機課程的意義 瀏覽:252
安卓導航車標在是哪個文件夾 瀏覽:109
豆瓣程序員采訪報道 瀏覽:651
徽贏app怎麼更換手機號碼 瀏覽:898
byd宋經典app怎麼下 瀏覽:710
域名解析成ip地址通過什麼伺服器 瀏覽:787
伺服器怎麼更換埠 瀏覽:566
程序員不做死肥宅 瀏覽:419