|
|
@@ -19,7 +19,8 @@ public class JdbcUtils {
|
|
|
conn = DriverManager.getConnection(DATABASE_URL);//连接数据库zhou.db,不存在则创建
|
|
|
System.out.println("连接到SQLite数据库成功!");
|
|
|
create_bw_record();//初始化结构表
|
|
|
- create_bw_tightening();//初始化
|
|
|
+ create_bw_tightening();//初始化拧紧表
|
|
|
+ create_bw_prod();//初始化拉铆表
|
|
|
} catch (Exception e) {
|
|
|
// TODO Auto-generated catch block
|
|
|
close();//关闭数据库连接
|
|
|
@@ -288,23 +289,16 @@ public class JdbcUtils {
|
|
|
}
|
|
|
|
|
|
public static List<ProdReq> getProds() {
|
|
|
- //SQL语句
|
|
|
- String sql = "select id,gw,line_sn,type,sn,fout,sout,fmin,smin,fmax,smax,qty,serial_number,sync,record_time,ucode from bw_prod where sync = 0 order by id asc limit 100";
|
|
|
- Connection conn = JdbcUtils.getConn();
|
|
|
- Statement stmt=null;
|
|
|
- ResultSet ret = null;
|
|
|
- String password=null;
|
|
|
List<ProdReq> prods = new ArrayList<>();
|
|
|
try {
|
|
|
- // 确保连接已经打开
|
|
|
- if (JdbcUtils.conn == null || JdbcUtils.conn.isClosed()) {
|
|
|
- JdbcUtils.openConnection();
|
|
|
+ if (conn == null || conn.isClosed()) {
|
|
|
+ openConnection();
|
|
|
}
|
|
|
|
|
|
- stmt = conn.createStatement();
|
|
|
- //执行语句,得到结果集
|
|
|
- ret = stmt.executeQuery(sql);
|
|
|
- System.out.println("sql:"+ sql);
|
|
|
+ String sql = "select id,gw,line_sn,type,sn,fout,sout,fmin,smin,fmax,smax,qty,serial_number,sync,record_time,ucode from bw_prod where sync = 0 order by id asc limit 100";
|
|
|
+ Statement statement = conn.createStatement();
|
|
|
+ ResultSet ret = statement.executeQuery(sql);
|
|
|
+ System.out.println("sql:" + sql);
|
|
|
while (ret.next()) {
|
|
|
ProdReq prodReq = new ProdReq();
|
|
|
prodReq.setId(ret.getInt(1));
|
|
|
@@ -326,7 +320,7 @@ public class JdbcUtils {
|
|
|
prods.add(prodReq);
|
|
|
}
|
|
|
ret.close();
|
|
|
- conn.close();//关闭连接
|
|
|
+ statement.close();
|
|
|
} catch (SQLException e1) {
|
|
|
e1.printStackTrace();
|
|
|
}
|