?? 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 + -