📄 frmblcxdb.java
字号:
package db.FrmBlcxDb;
import java.sql.*;
public class FrmBlcxDb {
private String dbDriver = null;//驱动字符串
private String dbConnStr = null;//连接字符串
private Connection conn; //连接对象
private Statement stmt; //JDBC声明
private String psSQL = null;
public ResultSet rsBrxx = null;
public ResultSet rsBlxx = null;
//病历信息
public String ZDRQ;
public String JBDM;
public String ZDYS;
public String ZD;
public String SFRCY;
/**
* 函数名:getConnection
* 编写者:YJ
* 功 能:数据库连接初始化,得到数据库连接
* 输入参数:无
* 输出参数:布尔型
* 备 注:
*/
public boolean getConnection()
{
try
{
//配置数据库驱动程序
dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
dbConnStr = "jdbc:odbc:Dbserver";
//加载驱动程序
Class.forName(dbDriver);
//创建连接
conn = DriverManager.getConnection(dbConnStr);
//设置不自动提交
conn.setAutoCommit(false);
//设置事务级别
conn.setTransactionIsolation(conn.TRANSACTION_READ_COMMITTED);
//创建一个JDBC声明
stmt = conn.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE,
ResultSet.CONCUR_READ_ONLY);
}
catch(Exception e)
{
System.out.print(e.getMessage());
e.printStackTrace();
return false;
}
return true;
}
/**
* 函数名:getBrxx
* 编写者:xx
* 功 能:查询病人信息
* 输入参数:N个
* 输出参数:病人信息
* 备 注:
*/
public String getBrxx(String[] strBrxx){
String getBrxx = null;
try {
//sql字符串
String strSQL = "";
strSQL = "SELECT * from [view_BRZYXX]";
strSQL = strSQL + " where ZYH like '%" + strBrxx[0] + "%'";
strSQL = strSQL + " and BLH like '%" + strBrxx[1] + "%'";
strSQL = strSQL + " and BRXM like '%" + strBrxx[2] + "%'";
strSQL = strSQL + " and ISNULL(BRXB,'') like '%" + strBrxx[3] + "%'";
strSQL = strSQL + " and ISNULL(CSNY,'') like '%" + strBrxx[4] + "%'";
strSQL = strSQL + " and ISNULL(SFZH,'') like '%" + strBrxx[5] + "%'";
strSQL = strSQL + " and ZYKS like '%" + strBrxx[6] + "%'";
strSQL = strSQL + " and ISNULL(BCH,'') like '%" + strBrxx[7] + "%'";
strSQL = strSQL + " and ISNULL(BRDH,'') like '%" + strBrxx[8] + "%'";
strSQL = strSQL + " and ISNULL(BRDZ,'') like '%" + strBrxx[9] + "%'";
strSQL = strSQL + " and ISNULL(LXRXM,'') like '%" + strBrxx[10] + "%'";
strSQL = strSQL + " and ISNULL(LXRDH,'') like '%" + strBrxx[11] + "%'";
strSQL = strSQL + " and ISNULL(LXRDZ,'') like '%" + strBrxx[12] + "%'";
strSQL = strSQL + " and RYRQ like '%" + strBrxx[13] + "%'";
strSQL = strSQL + " and ISNULL(CYRQ,'') like '%" + strBrxx[14] + "%'";
//System.out.println(strSQL);
//执行sql结果保存在动态集里
rsBrxx = stmt.executeQuery(strSQL);
return "ok";
} catch (Exception se) {
System.out.println(se.getMessage());
se.printStackTrace();
return "error";
}
//return getBrxx;
}
/**
* 函数名:getBlxx
* 编写者:xx
* 功 能:查询病历信息
* 输入参数:BLH
* 输出参数:病历信息
* 备 注:
*/
public String getBlxx(String BLH){
String getBlxx = null;
try {
//sql字符串
String strSQL = "";
strSQL = "SELECT * from [ZDJL] where BLH='" + BLH + "'";
//执行sql结果保存在动态集里
rsBlxx = stmt.executeQuery(strSQL);
return "ok";
} catch (Exception se) {
System.out.println(se.getMessage());
se.printStackTrace();
return "error";
}
//return getBlxx;
}
//关闭数据库连接
public void closeDB()
{
try
{
//在系统连接关闭之前,将所有未能及时提交的事务释放
conn.commit();
//关闭连接
if (!conn.isClosed())
conn.close();
}
catch(SQLException se)
{
System.out.print(se.getMessage());
se.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -