Java codepackage dao;
import java.sql.CallableStatement;
import java.sql.Connection;
import util.MyConnection;
public class GbDao {
private Connection conn = null;
private CallableStatement cs=null;
public void initConnection() throws Exception {
MyConnection myconn= new MyConnection(); //初始化MyConnection对象
conn = myconn.getConnection(); //调用MyConnection的getConnection()方法得到数据库连接
}
public String gbht(String gwm,String zmlm){
String msg=null;
String sql="{?=call F_HD_GBHT(?,?)}";
System.out.println("sql="+sql);
try{this.initConnection();
CallableStatement cs=conn.prepareCall(sql);
cs.registerOutParameter(1, java.sql.Types.VARCHAR);
cs.setString(2, gwm);
cs.setString(3, zmlm);
cs.execute();
msg=cs.getString(1);
}catch(Exception ex){
ex.printStackTrace();
}finally{
try{
if(cs!=null){
cs.close();
}
}catch(Exception ex){
ex.printStackTrace();
}
}
return msg;
}
}