如何使用 Java 实现对比两个 sql 文件
1个回答
2018-11-18 · 百度知道合伙人官方认证企业
关注
展开全部
List sqlFileList = new ArrayList();从文件读放内容到按分号放到sqlFileList public List readSqlFiles(List fileNameList) { List sqlList = new ArrayList(); for (String fileName : fileNameList) { File myFile = new File(fileName); if (!myFile.exists()) { System.err.println("Can't Find " + fileName); continue; } StringBuffer temp = new StringBuffer(); try { BufferedReader in = new BufferedReader(new FileReader(myFile)); String str; while ((str = in.readLine()) != null) { temp.append(str); } in.close(); } catch (IOException e) { e.getStackTrace(); } String sqls[] = temp.toString().split(";"); for (String sql : sqls) { sqlList.add(sql); } } return sqlList; }然后一句句的执行for (String sql : sqlList) {pstmt = con.prepareStatement(sql, ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY);pstmt.execute();}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询