?? frmbrcydb.java
字號:
package myprojects.FrmBRCYDb;
import java.sql.*;
public class FrmBRCYDb
{
public ResultSet rs = null;
public boolean flg = false;
private String dbDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
private String dbConn = "jdbc:odbc:Dbserver";
private Connection con;
private Statement stmt;
//連接數據庫
public void getConnection() {
try {
//加載驅動程序
Class.forName(dbDriver);
//建立連接
con = DriverManager.getConnection(dbConn);
//關閉自動提交
con.setAutoCommit(false);
//設定事務級別
con.setTransactionIsolation(con.TRANSACTION_SERIALIZABLE);
//創建一個JDBC聲明
stmt = con.createStatement();
}
catch (Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
}
//-------------------------------------------------------------------------
public boolean getBRCY(String s){
//String[] strZyks=new String[5];
try{
//ResultSet rs=new ResultSet();
String strSQL="";
strSQL="select * from RCYJL";
strSQL=strSQL+" where ZYH='"+s+"'";
System.out.println(strSQL);
rs=stmt.executeQuery(strSQL);
//rs=stmt.executeQuery(strSQL);
System.out.println("Test");
}
catch (SQLException e) {
//System.out.println(e.getMessage());
e.printStackTrace();
return false;
}
return true;
}
//--------------------------------------------------------------------------------
public String getNowDate() {
String getNowDate = null;
try {
//sql字符串
String strSQL = "";
strSQL = "SELECT SUBSTRING(CONVERT(VARCHAR(16),GETDATE(),120),1,16) AS SYSDATE";
//執行sql結果保存在動態集里
ResultSet rst = stmt.executeQuery(strSQL);
while(rst.next()){
getNowDate = rst.getString("SYSDATE");
}
} catch (Exception se) {
System.out.println(se.getMessage());
se.printStackTrace();
}
return getNowDate;
}
//------------------------------------------------------------------
public boolean getJFJL(String s){
try{
String strSQL="";
strSQL="select * from JFJL";
strSQL=strSQL+" where ZYH='"+s+"'";
System.out.println(strSQL);
rs=stmt.executeQuery(strSQL);
System.out.println("Test");
}
catch (SQLException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean getWJZFY(String s){
try{
String strSQL="";
strSQL="select * from View_WJZFY";
strSQL=strSQL+" where ZYH='"+s+"'" ;
System.out.println(strSQL);
rs=stmt.executeQuery(strSQL);
System.out.println("Test");
}
catch (SQLException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean getBRZYXX(String s){
try{
String strSQL="";
strSQL="select * from View_BRZYXX";
strSQL=strSQL+" where ZYH='"+s+"'" ;
System.out.println(strSQL);
rs=stmt.executeQuery(strSQL);
System.out.println("Test");
}
catch (SQLException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean getJBDM(String s){
try{
String strSQL="";
strSQL="select * from JBDM";
strSQL=strSQL+" where ICD LIKE '%"+s+"%'" ;
System.out.println(strSQL);
rs=stmt.executeQuery(strSQL);
System.out.println("Test");
}
catch (SQLException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean getJBMC(String s){
try{
String strSQL="";
strSQL="select * from JBDM";
strSQL=strSQL+" where JBMC LIKE '%"+s+"%'" ;
System.out.println(strSQL);
rs=stmt.executeQuery(strSQL);
System.out.println("Test");
}
catch (SQLException e) {
e.printStackTrace();
return false;
}
return true;
}
public boolean updateRCYJL(String strCyrq,String strZyh){
String strSQL="";
strSQL="UPDATE RCYJL SET CYRQ='";
strSQL=strSQL+strCyrq+"' WHERE ZYH='"+strZyh+"'";
System.out.println(strSQL);
try{
stmt.executeUpdate(strSQL);
con.commit();
}
catch(SQLException e){
return false;
}
return true;
}
public boolean insertZDJL(String strBlh,String strZdrq,String strJbdm,String strZdys,String strZd,String strSfrcy){
String strSQL="";
strSQL="INSERT INTO ZDJL VALUES('";
strSQL=strSQL+strBlh+"','"+strZdrq+"','"+strJbdm+"','"+strZdys+"','"+strZd+"','"+strSfrcy+"')";
System.out.println(strSQL + " 11111");
try{
stmt.executeUpdate(strSQL);
con.commit();
}
catch(SQLException e){
return false;
}
return true;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -