java使用jdbc对sqlite 添加、删除、修改的操作
package com.jb.jubmis.Dao.DaoImpl;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;
import com.jb.jubmis.Dao.SqliteDao;
import com.jb.jubmis.entity.ContactHistorys;
import com.jb.jubmis.entity.ContactPlans;
import com.jb.jubmis.entity.SalesTask;
import com.jb.jubmis.entity.Scheduals;
import com.jb.jubmis.entity.Tradings;
import com.jb.jubmis.entity.Xskh;
public class SqliteDaoImpl implements SqliteDao {
public List<Xskh> qryGetAll() throws SQLException {
ResultSet rs = null;
Connection conn = null;
Statement stat = null;
List<Xskh> list = new ArrayList<Xskh>();
try {
conn = connOpen();
stat = conn.createStatement();
rs = stat.executeQuery(" select * from xskh "); // 查询数据
while (rs.next()) {
Xskh xskh = new Xskh();
xskh.setAguid(rs.getString("aguid"));
xskh.setPguid(rs.getString("pguid"));
xskh.setStatus(rs.getInt("status"));
xskh.setPxxh(rs.getInt("pxxh"));
xskh.setRemark(rs.getString("remark"));
// xskh.setLastsqlupd(rs.getString("lastupdate"));
xskh.setAname(rs.getString("aname"));
xskh.setAnameLong(rs.getString("aname_long"));
xskh.setTel(rs.getString("tel"));
xskh.setMobile(rs.getString("mobile"));
xskh.setEmail(rs.getString("email"));
xskh.setAddr(rs.getString("addr"));
xskh.setKfPeo(rs.getString("kf_peo"));
xskh.setGuidJb(rs.getString("guid_jb"));
xskh.setGuidKind(rs.getString("guid_kind"));
xskh.setGuidFrom(rs.getString("guid_from"));
xskh.setGuidSheng(rs.getString("guid_sheng"));
xskh.setGuidShi(rs.getString("guid_shi"));
xskh.setDateCreate(rs.getString("date_create"));
xskh.setDateLastupdate(rs.getString("date_lastupd"));
xskh.setDateLastcheck(rs.getString("date_lastcontact"));
xskh.setDateLastin(rs.getString("date_lastin"));
xskh.setGuidYw(rs.getString("guid_yw"));
xskh.setKfPeoBirthday(rs.getString("kf_peo_birthday"));
xskh.setZjm(rs.getString("zjm"));
list.add(xskh);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
rs.close();
stat.close();
conn.close();
}
return list;
}
public void saveInfo(Xskh xskh) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
// String sql=" insert into xskh" +
// "(aguid,pguid,pxxh,status,guid_yw,guid_Lastupd,guid_Jb,guid_Kind,guid_from,guid_brand,guid_sheng,guid_shi,guid_xian,guid_fhkind,guid_station,acode,aname,aname_long,tax_no,zjm,tel,mobile,fax,addr,sh_Addr,postcode,www,email,qq,kf_peo,kf_peo_bm,kf_peo_zhiwei,kf_peo_birthday,kf_peo_tel,wl_times,thday,date_create,date_lastupdate,date_lastin,date_lastout,kf_peo2,kf_tel2,kf_peo3,kf_tel3,zk_kind,zk_fix,zk_min,thratio,thratio_calc,remark,likeme,jycontent,payment,date_lastcheck,sy_year,mainsale_kcsp,date_begindeal,photo1,photo2,xsrl,xsyc,jy_area,company_pw,date_lastgj,lastsqlupd)"
// +
// " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String sql = " insert into xskh"
+ "(aguid,pguid,status,pxxh,remark,aname,aname_long,tel,mobile,email,addr,kf_peo,guid_jb,guid_kind,guid_from,guid_sheng,guid_shi,date_create,date_lastupd,date_lastcontact,"
+ "date_lastin,guid_yw,kf_peo_birthday,zjm)"
+ " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
conn = connOpen();
stat = conn.prepareStatement(sql);
stat.setString(1, xskh.getAguid());
stat.setString(2, xskh.getPguid());
stat.setInt(3, xskh.getStatus());
stat.setInt(4, xskh.getPxxh());
stat.setString(5, xskh.getRemark());
stat.setString(6, xskh.getAname());
stat.setString(7, xskh.getAnameLong());
stat.setString(8, xskh.getTel());
stat.setString(9, xskh.getMobile());
stat.setString(10, xskh.getEmail());
stat.setString(11, xskh.getAddr());
stat.setString(12, xskh.getKfPeo());
stat.setString(13, xskh.getGuidJb());
stat.setString(14, xskh.getGuidKind());
stat.setString(15, xskh.getGuidFrom());
stat.setString(16, xskh.getGuidSheng());
stat.setString(17, xskh.getGuidShi());
stat.setString(18, xskh.getDateCreate());
stat.setString(19, xskh.getDateLastupdate());
stat.setString(20, xskh.getDateLastcheck());
stat.setString(21, xskh.getDateLastin());
stat.setString(22, xskh.getGuidYw());
stat.setString(23, xskh.getKfPeoBirthday());
stat.setString(24, xskh.getZjm());
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
public void updateInfo(Xskh xskh) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
String sql = " update xskh"
+ "(aguid,pguid,status,pxxh,remark,aname,aname_long,tel,mobile,email,addr,kf_peo,guid_jb,guid_kind,guid_from,guid_sheng,guid_shi,date_create,date_lastupd,date_lastcontact,"
+ "date_lastin,guid_yw,kf_peo_birthday,zjm)"
+ " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
conn = connOpen();
stat = conn.prepareStatement(sql);
stat.setString(1, xskh.getAguid());
stat.setString(2, xskh.getPguid());
stat.setInt(3, xskh.getStatus());
stat.setInt(4, xskh.getPxxh());
stat.setString(5, xskh.getRemark());
stat.setString(6, xskh.getAname());
stat.setString(7, xskh.getAnameLong());
stat.setString(8, xskh.getTel());
stat.setString(9, xskh.getMobile());
stat.setString(10, xskh.getEmail());
stat.setString(11, xskh.getAddr());
stat.setString(12, xskh.getKfPeo());
stat.setString(13, xskh.getGuidJb());
stat.setString(14, xskh.getGuidKind());
stat.setString(15, xskh.getGuidFrom());
stat.setString(16, xskh.getGuidSheng());
stat.setString(17, xskh.getGuidShi());
stat.setString(18, xskh.getDateCreate());
stat.setString(19, xskh.getDateLastupdate());
stat.setString(20, xskh.getDateLastcheck());
stat.setString(21, xskh.getDateLastin());
stat.setString(22, xskh.getGuidYw());
stat.setString(23, xskh.getKfPeoBirthday());
stat.setString(24, xskh.getZjm());
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
public void daleteInfo(Xskh xskh) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
String sql = "delete from xskh where aguid='" + xskh.getAguid()
+ "'";
conn = connOpen();
stat = conn.prepareStatement(sql);
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
public Connection connOpen() throws SQLException {
Connection conn = null;
try {
Class.forName("org.sqlite.JDBC");//驱动我这里导入的驱动是sqlitejdbc-v056.jar
conn = DriverManager
.getConnection("jdbc:sqlite:D:\\eclipse\\project\\jee\\workspace\\jubmis\\WebRoot\\WEB-INF\\ebusiness.db");//db文件
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
return conn;
}
public Integer qryMaxPxxh() throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
ResultSet rs = null;
try {
String sql = "select max(pxxh) as pxxh from xskh ";
conn = connOpen();
stat = conn.prepareStatement(sql);
rs = stat.executeQuery();
if (rs.next()) {
Integer pxxh = rs.getInt("pxxh");
if (pxxh == null) {
return 1;
}
return pxxh + 1;
} else {
return 1;
}
} catch (Exception e) {
e.printStackTrace();
} finally {
rs.close();
stat.close();
conn.close();
}
return 1;
}
public void saveInfo(ContactHistorys contactHistorys) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
String sql = " insert into xskh_touch "
+ "(aguid,pguid,status,pxxh,remark,lastupdate,guid_kind,guid_style,guid_kh,guid_work,date_work)"
+ "values(?,?,?,?,?,?,?,?,?,?,?)";
conn = connOpen();
stat = conn.prepareStatement(sql);
stat.setString(1, contactHistorys.getId());
stat.setString(2, contactHistorys.getPid());
stat.setInt(3, contactHistorys.getStatus());
stat.setInt(4, contactHistorys.getSerialNum());
stat.setString(5, contactHistorys.getRemark());
stat.setString(6, contactHistorys.getTheLastOfUpdate());
stat.setString(7, contactHistorys.getContactType());
stat.setString(8, contactHistorys.getContactWay());
stat.setString(9, contactHistorys.getCustomer());
stat.setString(10, contactHistorys.getUser());
stat.setString(11, contactHistorys.getTimeOfContact());
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
public void saveInfo(ContactPlans contactPlans) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
String sql = " insert into xskh_waring "
+ "(aguid,pguid,status,pxxh,remark,lastupdate,date_work,date_waring,guid_user,guid_kh)"
+ "values(?,?,?,?,?,?,?,?,?,?)";
conn = connOpen();
stat = conn.prepareStatement(sql);
stat.setString(1, contactPlans.getId());
stat.setString(2, contactPlans.getPid());
stat.setInt(3, contactPlans.getStatus());
stat.setInt(4, contactPlans.getSerialNum());
stat.setString(5, contactPlans.getRemark());
stat.setString(6, contactPlans.getTheLastOfUpdate());
stat.setString(7, contactPlans.getDateCreate());
stat.setString(8, contactPlans.getDateWarning());
stat.setString(9, contactPlans.getUser());
stat.setString(10, contactPlans.getCustomer());
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
public void saveInfo(SalesTask salesTask) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
String sql = " insert into xskh_task "
+ "(aguid,pguid,status,pxxh,remark,lastupdate,sy_goal,sy_task,date_yw,date_lastupd)"
+ "values(?,?,?,?,?,?,?,?,?,?)";
conn = connOpen();
stat = conn.prepareStatement(sql);
stat.setString(1, salesTask.getId());
stat.setString(2, salesTask.getPid());
stat.setInt(3, salesTask.getStatus());
stat.setInt(4, salesTask.getSerialNum());
stat.setString(5, salesTask.getRemark());
stat.setString(6, salesTask.getTheLastOfUpdate());
stat.setDouble(7, salesTask.getGoal());
stat.setInt(8, salesTask.getContact());
stat.setString(9, salesTask.getTaskMonth());
stat.setString(10, salesTask.getDateOfLastUpdate());
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
public void saveInfo(Scheduals scheduals) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
String sql = " insert into msg_m "
+ "(aguid,pguid,status,pxxh,remark,lastupdate,aname,date_send,date_begin,guid_sender,dllformclass)"
+ "values(?,?,?,?,?,?,?,?,?,?,?)";
conn = connOpen();
stat = conn.prepareStatement(sql);
stat.setString(1, scheduals.getId());
stat.setString(2, scheduals.getPid());
stat.setInt(3, scheduals.getStatus());
stat.setInt(4, scheduals.getSerialNum());
stat.setString(5, scheduals.getRemark());
stat.setString(6, scheduals.getTheLastOfUpdate());
stat.setString(7, scheduals.getTopic());
stat.setString(8, scheduals.getDateCreate());
stat.setString(9, scheduals.getDateWarning());
stat.setString(10, scheduals.getUser());
stat.setString(11, scheduals.getResult());
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
public void saveInfo(Tradings tradings) throws SQLException {
Connection conn = null;
PreparedStatement stat = null;
try {
String sql = " insert into xsbilldd_m "
+ "(aguid,pguid,status,pxxh,remark,lastupdate,guid_kh,guid_yw,qty,sy_fee,bj,date_yw)"
+ "values(?,?,?,?,?,?,?,?,?,?,?,?)";
conn = connOpen();
stat = conn.prepareStatement(sql);
stat.setString(1, tradings.getId());
stat.setString(2, tradings.getPid());
stat.setInt(3, tradings.getStatus());
stat.setInt(4, tradings.getSerialNum());
stat.setString(5, tradings.getRemark());
stat.setString(6, tradings.getTheLastOfUpdate());
stat.setString(7, tradings.getGuid_kh());
stat.setString(8, tradings.getUser());
stat.setDouble(9, tradings.getNumber());
stat.setDouble(10, tradings.getCost());
stat.setDouble(11, tradings.getPrice());
stat.setString(12, tradings.getDate());
stat.executeUpdate();
} catch (Exception e) {
e.printStackTrace();
} finally {
stat.close();
conn.close();
}
}
java使用jdbc对sqlite 添加、删除、修改的操作的更多相关文章
- MySQL_(Java)使用JDBC向数据库中删除(delete)数据
MySQL_(Java)使用JDBC向数据库发起查询请求 传送门 MySQL_(Java)使用JDBC向数据库中插入(insert)数据 传送门 MySQL_(Java)使用JDBC向数据库中删除(d ...
- JTree 添加 , 删除, 修改
package com.swing.demo; import java.awt.BorderLayout; import java.awt.Container; import java.awt.eve ...
- Dom4j 操作, 节点查找 添加 删除 修改 。。。xPath
转: Dom4j 操作, 节点查找 添加 删除 修改 ...xPath 2013年11月28日 10:48:59 今晚打酱油8 阅读数:8506更多 个人分类: JavaWeb 版权声明:本文为博 ...
- SQL语句添加删除修改字段及一些表与字段的基本操作
用SQL语句添加删除修改字段 1.增加字段 alter table docdsp add dspcode char(200)2.删除字段 ALTER TABLE table_NA ...
- Entity framework 绑定到Datagridview的添加删除修改
Entity framework 绑定到Datagridview的添加删除修改 using System; using System.Collections.Generic; using System ...
- JavaScript学习 - 基础(八) - DOM 节点 添加/删除/修改/属性值操作
html代码: <!--添加/删除/修改 --> <div id="a1"> <button id="a2" onclick=&q ...
- 用SQL语句添加删除修改字段、一些表与字段的基本操作、数据库备份等
用SQL语句添加删除修改字段 1.增加字段 alter table docdsp add dspcode char(200) 2.删除字段 ALTER TABLE table_NAME DROP CO ...
- SQL语句添加删除修改字段[sql server 2000/2005]
用SQL语句添加删除修改字段1.增加字段 alter table docdsp add dspcodechar(200)2.删除字段 ALTER TABLE table_NAME ...
- SQL语句添加删除修改字段
用SQL语句添加删除修改字段1.增加字段 alter table docdsp add dspcodechar(200)2.删除字段 ALTER TABLE table_NAME ...
随机推荐
- HDU5463 Clarke and minecraft
解题思路:此题刚开始,觉得好繁琐,好混乱,理清思路后,发现很简单. 具体见代码分析. #include<cstdio> #include<cstring> #include ...
- HttpWebRequest模拟c#网站登录
用户名 密码 模拟登录asp.net开发的网站 关心两个问题:通过控件属性获取数据.响应事件. 上面是一个普通的asp.net表单.输入用户名.密码后,点击按钮将会进入各自绑定的后台函数,而不仅仅是 ...
- zoj 2105 Lifting the Stone
题意 裸的计算几何 求多边形重心: #include<iostream> #include<stdio.h> #include<cstring> #inclu ...
- ssl创建自签名的https通信
ssl协议:ssl在tcp之上,http之下.兼容底层协议.所以推广起来很容易. create a self-signed server certificate -- for test purpose ...
- mysql 表日常变化前几
mysql 表日常变化前几use performance_schema create table test.snap1 as SELECT OBJECT_SCHEMA, OBJECT_NAME, CO ...
- jquery easyui datagrid字段绑定问题
表字段为G_XIAN,生成PO对象时为private String GXian; datagrid字段必须写为gXian,否则数据无法正确绑定. 总结:不管VO对象中字段名称首字母是否大写,在data ...
- 读取Assets中的文件数据
try { // 返回的字节流 InputStream is = getResources().getAssets().open("info.txt"); // 当读取时,属于文本 ...
- hihocoder 1356 分隔相同整数 简单贪心
分析:考虑贪心,考虑填ans[i],前i-1个合法,现在剩下一些数, 那么挑出出现次数最多的数,次数为mx,当前剩余总数为sum 如果sum-mx>=mx-1那么肯定有解,这个想想就知道了(这种 ...
- python与saltstack动态传参变量名的研究
python动态变量名 import sys createVar = locals() listTemp = range(1,10) for i in range(1, len(sys.argv)): ...
- 使用Ajax在javascript中调用后台C#函数
使用Ajax在javascript中调用后台C#函数 最近一段时间在紧跟一个网站的项目,数据库中用户表的UserName要求是唯一的,所以当用户选定一个用户名进行注册时要首先检查该用户名是否已被占用, ...