package com.jjia.iosql;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
public class SubscribeInfo {
public void readIo() throws IOException, SQLException {
SubscribeInfo subscribeInfo = new SubscribeInfo();
@SuppressWarnings("resource")
BufferedReader bufferedReader = new BufferedReader(new FileReader(
"e:/SubscribeInfo194.req"));
String data = bufferedReader.readLine();
while (data != null) {
String telNumbText = null;
String statusText = null;
int statusUpdate1 = 0;
int statusUpdate2 = 0;
String statusSqlopType = null;
int statusSqlsid = 0;
int statusSqlschid = 0;
int statusSqlid = 0;
// ResultSet rs = subscribeInfo
// .findParam("select * from t_serviceLog s,t_parent p where s.sid=p.sid");
// subscribeInfo.findParam("select top 1 * from t_parent","sid");
// while (rs.next())
// System.out.println(rs.getString("sid"));
data = bufferedReader.readLine();
String[] datas = data.split("\t");
telNumbText = datas[2];
statusText = datas[6];
System.out.println(statusText);
if (statusText.equals("1")) {
// while (rs.next()) {
statusSqlopType = subscribeInfo
.findParam("select s.operationType from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","operationType");
statusSqlsid = subscribeInfo
.findParam1("select s.sid from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","sid");
statusSqlschid = subscribeInfo
.findParam1("select s.schoolid from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","schoolid");
statusSqlid = subscribeInfo
.findParam1("select s.id from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","id");
// statusSql = rs.getString("s.operationType");
if (!statusSqlopType.equals("10")) {
statusUpdate1 = subscribeInfo
.updateSql("update t_servicelog set expirationdate=getdate(),[enable]=0 where id="
+ "'" + statusSqlid + "'");
statusUpdate2 = subscribeInfo
.updateSql("insert into t_servicelog (xh,[sid],servicetype,operationtype,effectivedate,expirationdate,expirationreason,schoolid,usertype,[enable]) "
+ "values(0,"
+ "'"
+ statusSqlsid
+ "'"
+ ",'JXT','10',getdate(),'2043-10-31','代收费',"
+ "'" + statusSqlschid + "'" + ",'1','1')");
}
// }
System.out.println("--------系统中共有" + statusUpdate1
+ "条记录受影响-----------");
System.out.println("号码:"+telNumbText);
System.out.println("---------共插入" + statusUpdate2
+ "条数据------------");
} else if (statusText.equals("2")) {
// while (rs.next()) {
statusSqlopType = subscribeInfo
.findParam("select s.operationType from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","operationType");
statusSqlsid = subscribeInfo
.findParam1("select s.sid from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","sid");
statusSqlschid = subscribeInfo
.findParam1("select s.schoolid from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","schoolid");
statusSqlid = subscribeInfo
.findParam1("select s.id from t_serviceLog s,t_parent p where s.sid=p.sid and s.enable='1' and p.mobileid="
+ "'" + telNumbText + "'","id");
// statusSql = rs.getString("s.operationType");
if (!statusSqlopType.equals("15")) {
statusUpdate1 = subscribeInfo
.updateSql("update t_servicelog set expirationdate=getdate(),[enable]=0 where id="
+ "'" + statusSqlid + "'");
statusUpdate2 = subscribeInfo
.updateSql("insert into t_servicelog (xh,[sid],servicetype,operationtype,effectivedate,expirationdate,expirationreason,schoolid,usertype,[enable]) "
+ "values(0,"
+ "'"
+ statusSqlsid
+ "'"
+ ",'JXT','15',getdate(),'2099-12-31','系统退订',"
+ "'" + statusSqlschid + "'" + ",'1','1')");
}
// }
System.out.println("--------系统中共有" + statusUpdate1
+ "条记录受影响-----------");
System.out.println("---------共插入" + statusUpdate2
+ "条数据------------");
}
}
}
public String findParam(String sql,String column) {
Statement stmt;
Connection conn;
ResultSet rs = null;
String value = "";
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1491;DatabaseName=database";
conn = DriverManager.getConnection(url, "sa", "123456");
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if (rs.next()) {
value = rs.getString(column);
}
return value;
} catch (Exception e) {
// TODO Auto-generated catch block
System.out.println(sql);
e.printStackTrace();
}
return null;
}
public int findParam1(String sql,String column) {
Statement stmt;
Connection conn;
ResultSet rs = null;
int value = 0;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1491;DatabaseName=database";
conn = DriverManager.getConnection(url, "sa", "123456");
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if (rs.next()) {
value = rs.getInt(column);
}
return value;
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return 0;
}
public int updateSql(String sql) {
Statement stmt;
Connection conn;
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
String url = "jdbc:sqlserver://localhost:1491;DatabaseName=database";
conn = DriverManager.getConnection(url, "sa", "123456");
stmt = conn.createStatement();
return stmt.executeUpdate(sql);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
public static void main(String[] args) throws IOException, SQLException {
SubscribeInfo subscribeInfo = new SubscribeInfo();
subscribeInfo.readIo();
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
ioSql.zip (7个子文件)
ioSql
.project 381B
bin
com
jjia
iosql
SubscribeInfo.class 6KB
IoTest.class 1KB
.settings
org.eclipse.jdt.core.prefs 598B
src
com
jjia
iosql
SubscribeInfo.java 6KB
IoTest.java 555B
.classpath 384B
共 7 条
- 1
资源评论
- jiuding20122012-10-16对于使用io流读取文件的内容操作比较详细,还有连接数据库的操作。只是注释写的比较少,代码运行是没有错的。
yoosha
- 粉丝: 4
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- DatabaseWatermarkingBasedonTextFormat
- -移动通信-网络课程设计与研究
- 基于Python的PCA人脸识别算法的原理及实现代码+文档详解.zip
- 甘肃移动全业务工程建设项目管理流程优化研究
- 549springboot + vue 民宿管理平台.zip (可运行源码+数据库文件+文档)
- ZArchiver.Pro_0.9.5.apk
- vmware环境配置.mp4
- 548springboot + vue 大学生社团活动平台.zip(可运行源码+数据库文件+文档)
- 微信小程序 辩论倒计时小程序源码 作业设计demo 计算机专业参考
- 深入探究文件IO,嵌入式Linux
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功