标签:
<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
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
-
-
-
- <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
-
- <property name="driverClassName" value="org.sqlite.JDBC" />
-
- <property name="url" value="jdbc:sqlite:C:/Users/anialy/Desktop/workspace/MyProj/db/MY_DB" />
- </bean>
-
-
- <bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
- <property name="dataSource">
- <ref local="dataSource" />
- </property>
- </bean>
-
-
- <bean id="appDao" class="com.anialy.myproj.dao.AppDao">
- <property name="jdbcTemplate">
- <ref local="jdbcTemplate" />
- </property>
- </bean>
-
- <bean id="versionDao" class="com.anialy.myproj.dao.VersionDao">
- <property name="jdbcTemplate">
- <ref local="jdbcTemplate" />
- </property>
- </bean>
-
- </beans>
在web.xml中添上
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener
- </listener-class>
- </listener>
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>
- classpath:applicationContext-dao.xml
- </param-value>
- </context-param>
sqllite
标签:
原文地址:http://www.cnblogs.com/zouhao510/p/5460433.html