SQLITE使用指南

前端之家收集整理的这篇文章主要介绍了SQLITE使用指南前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

sqlITE是一个轻型的数据库,广泛应用与嵌入式系统当中,支持多种开发语言,C,PHP,Perl,Java,C#,Python。它有体积小,效率高,可移植性好的优点
sqlite及sqlite-jdbc下载地址:见附件
JAVA-DEMO

Java代码

复制代码

收藏代码

  1. public class Test {
  2. public static void main(String[] args) throws Exception {
  3. Class.forName("org.sqlite.JDBC");
  4. Connection conn =
  5. DriverManager.getConnection("jdbc:sqlite:demo.db");
  6. Statement stat = conn.createStatement();
  7. stat.executeUpdate("drop table if exists people;");
  8. stat.executeUpdate("create table people (name,occupation);");
  9. PreparedStatement prep = conn.prepareStatement(
  10. "insert into people values (?,?);");
  11. prep.setString(1,"Gandhi");
  12. prep.setString(2,"politics");
  13. prep.addBatch();
  14. prep.setString(1,"Turing");
  15. prep.setString(2,"computers");
  16. prep.addBatch();
  17. prep.setString(1,"Wittgenstein");
  18. prep.setString(2,"smartypants");
  19. prep.addBatch();
  20. conn.setAutoCommit(false);
  21. prep.executeBatch();
  22. conn.setAutoCommit(true);
  23. ResultSet rs = stat.executeQuery("select * from people;");
  24. while (rs.next()) {
  25. System.out.println("name = " + rs.getString("name"));
  26. System.out.println("job = " + rs.getString("occupation"));
  27. }
  28. rs.close();
  29. conn.close();
  30. }
  31. }
原文链接:https://www.f2er.com/sqlite/201471.html

猜你在找的Sqlite相关文章