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