新增异常信息打印,修改接口

This commit is contained in:
Elliott
2024-04-16 11:54:06 +08:00
parent a1f96e12be
commit fc8e7ad795
6 changed files with 73 additions and 7 deletions

View File

@@ -158,5 +158,42 @@ public class HisViewSearchServiceImpl implements HisViewSearchService {
return medicalPrescriptions;
}
@Override
public List<MedicalPrescription> getMedicalPrescriptionByCardNo(String cardNo) {
log.info("拼接数据");
// String URL = "jdbc:sqlserver:thin:@//168.168.0.10:1433/THIS4";
String URL = "jdbc:sqlserver://168.168.0.10:1433;databaseName=THIS4";
String USER = "joju";
String PASSWORD = "Joju@123";
List<MedicalPrescription> medicalPrescriptions = null;
// 1.加载驱动程序
try {
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
// 2.获得数据库链接
log.info("开始链接数据库");
Connection conn = DriverManager.getConnection(URL, USER, PASSWORD);
log.info("打印链接状态:" + conn);
// 3.通过数据库的连接操作数据库实现增删改查使用Statement类
// SELECT * FROM HIS_WJFHZCFXX WHERE lrrq BETWEEN '2024-04-02 00:00:00' AND '2024-04-03 00:00:00 '
String sql = " SELECT * FROM HIS_WJFHZCFXX WHERE cardno = '" + cardNo + "'";
log.info("打印sql" + sql);
Statement statement = conn.createStatement();
ResultSet rs = statement.executeQuery(sql);
log.info("返回结果是:" + rs);
BeanListHandler<MedicalPrescription> medicalPrescriptionBeanListHandler = new BeanListHandler<>(MedicalPrescription.class);
medicalPrescriptions = medicalPrescriptionBeanListHandler.handle(rs);
log.info("list is " + medicalPrescriptions);
// 关闭资源【多谢指正】
rs.close();
statement.close();
conn.close();
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return medicalPrescriptions;
}
}