1.postgresql在win7安装参考
http://deepfuture.iteye.com/blog/587477
安装过程中如果缺少 MSVCR120.dll、MSVCP120.dll 在网上下载后,将dll文件复制到“ X:\Windows\system32 ” (X代表您系统所在目录盘符,如:C:\Windows\system32 ) 目录下。
2. 相关命令
initdb -D D:\dev\pgsql\data --locale=C
createdb -h 127.0.0.1 test_db
createuser -h 127.0.0.1 test_user
pg_ctl -D D:\dev\pgsql\data start
3. 相关sql
select now();
select * from user_info order by id desc limit 1;
insert into user_info(id,token,valid_time) values(nextval('seq_user_info'),'123',now()- interval '11 days');
delete from user where create_time<(now()+interval('2 months'));
update user_token set status='0' where create_time<(now()-interval('10 days'));
create sequence seq_user minvalue 1 maxvalue 9999999 increment by 1 start with 1 cache 10;
alter table user_info alter column id set default nextval('seq_user_info');
create table user_info(
id integer primary key default nextval('seq_user_info'),
name varchar(40) not null check (name <> '')
);
insert into user_info(name) values ('hfhwfw');
4. jdbc驱动包下载
https://jdbc.postgresql.org/download.html
4. 连接配置
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource"> <property name="driverClassName" value="org.postgresql.Driver" /> <property name="url" value="jdbc:postgresql://127.0.0.1:5432/test" /> <property name="username" value="user" /> <property name="password" value="pwd" /> </bean>Class.forName("org.postgresql.Driver"); Connection connection = DriverManager.getConnection("jdbc:postgresql://127.0.0.1:5432/test","user","pwd");