/*从该网站下载 http://www.ch-werner.de/javasqlite/*/
/*导入其中的jar包,并把dll文件放在程序同级目录即可*/
try {
Class clz = Class.forName("SQLite.JDBCDriver");
Connection conn = DriverManager.getConnection("jdbc:sqlite:/"+System.getProperty("user.dir")+"/RTCProfileStore.db");
String sql = "select MSG_INFO1 from SESSION_MESSAGE_HISTORY ";
PreparedStatement pst = conn.prepareStatement(sql);
ResultSet rs = pst.executeQuery();
if(rs.next()){
InputStream is = null;
is = rs.getBinaryStream("MSG_INFO1");
JOptionPane.showMessageDialog(this, "ok");
}
} catch (SQLException ex) {
Logger.getLogger(MainLocal.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, ex.getMessage());
} catch (ClassNotFoundException ex) {
Logger.getLogger(MainLocal.class.getName()).log(Level.SEVERE, null, ex);
JOptionPane.showMessageDialog(null, ex.getMessage());
}
本文介绍了一种使用Java连接并读取SQLite数据库的方法。通过下载特定网站上的资源,可以轻松地将SQLite数据库集成到Java应用程序中。示例代码展示了如何建立数据库连接、执行SQL查询并读取二进制数据。
1万+

被折叠的 条评论
为什么被折叠?



