zoukankan      html  css  js  c++  java
  • sqllite

    <dependency>
        <groupId>org.xerial</groupId>
        <artifactId>sqlite-jdbc</artifactId>
        <version>3.8.11.2</version>
    </dependency>

    1 安装

    去sqlite主页http://www.sqlite.org/.跳转到下载也http://www.sqlite.org/download.html。源码下载sqlite-amalgamation-3.7.3.tar.gz

    我去的时候是3.7.3版现在估计升级了。

    进入下载目录,解压文件tar -zxvf sqlite-amalgamation-3.7.3.tar.gz.

    解压后生成sqlite-3.7.3目录. cd 进入sqlite-3.7.3。

    ./configure

    make

    sudo make install

    安装完成。

    2测试

    在任意目录下新建一个数据库,比如student ,

    命令: sqlite3 student

    出现如下提示:

    SQLite version 3.7.2
    Enter ".help" for instructions
    Enter SQL statements terminated with a ";"
    sqlite>

    输入.help可以看到命令列表。

    输入sql语句create table user(username text primary key, password text); 建一张user表

    输入sql语句insert into user values("tianyou121", "123"); 插入一个用户。

    输入sql语句select * from user; 可以查看user表.

    输入sql命令是记得结尾的';'号。

    简述:

    记录Spring配置sqlite

    1. <?xml version="1.0" encoding="UTF-8"?>  
    2. <!-- 指定Spring配置文件的Schema信息 -->  
    3. <beans xmlns="http://www.springframework.org/schema/beans"  
    4.     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
    5.     xmlns:aop="http://www.springframework.org/schema/aop"  
    6.     xmlns:tx="http://www.springframework.org/schema/tx"  
    7.     xsi:schemaLocation="http://www.springframework.org/schema/beans   
    8.     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
    9.     http://www.springframework.org/schema/tx   
    10.     http://www.springframework.org/schema/tx/spring-tx-2.5.xsd  
    11.     http://www.springframework.org/schema/aop   
    12.     http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">  
    13.   
    14.   
    15.     <!-- 定义数据源Bean-->  
    16.     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">   
    17.         <!-- 指定连接数据库的驱动 -->  
    18.         <property name="driverClassName" value="org.sqlite.JDBC" />  
    19.         <!-- 指定连接数据库的URL -->  
    20.         <property name="url" value="jdbc:sqlite:C:/Users/anialy/Desktop/workspace/MyProj/db/MY_DB" />  
    21.     </bean>  
    22.   
    23.       
    24.     <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">  
    25.         <property name="dataSource">  
    26.             <ref local="dataSource" />  
    27.         </property>  
    28.     </bean>  
    29.   
    30.       
    31.     <bean id="appDao" class="com.anialy.myproj.dao.AppDao">  
    32.        <property name="jdbcTemplate">    
    33.             <ref local="jdbcTemplate" />    
    34.         </property>    
    35.     </bean>  
    36.       
    37.     <bean id="versionDao" class="com.anialy.myproj.dao.VersionDao">  
    38.         <property name="jdbcTemplate">    
    39.             <ref local="jdbcTemplate" />    
    40.         </property>    
    41.     </bean>  
    42.       
    43. </beans>  

    在web.xml中添上
    1. <listener>  
    2.   <listener-class>org.springframework.web.context.ContextLoaderListener    
    3.     </listener-class>  
    4. </listener>  
    5. <context-param>  
    6.   <param-name>contextConfigLocation</param-name>  
    7.   <param-value>  
    8.       classpath:applicationContext-dao.xml  
    9.   </param-value>  
    10. </context-param>  


     
  • 相关阅读:
    Hadoop运行环境搭建
    大数据技术快速扫盲篇
    基于Cloudera Manager Server的WebUI添加Hive服务实战案例
    基于Cloudera Manager Server的WebUI添加Spark服务实战案例
    zabbix的聚合图形配置实战案例
    zabbix配置短信报警概述
    zabbix配置微信报警实战案例
    基于Zabbix WebUI的API实现自动化添加主机实战案例
    zabbix监控 Nginx web页面实战案例
    zabbix agent批量安装并自动监控TCP的11种状态实战案例
  • 原文地址:https://www.cnblogs.com/zouhao510/p/5460433.html
Copyright © 2011-2022 走看看