⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 zjh.java

📁 这个是我们做土地局的一个项目。感觉不错。欢迎下载
💻 JAVA
字号:
package huayi.gg.zjh;

import java.sql.*;
import java.io.*;
import java.util.*;
import javax.naming.*;

/**
* ′óá??ó3??Dè?μ?ò??????Dμ?êy?Y?aá??ó
* @return Connection
* @exception Exception
*/
public class zjh{
Connection conn = null; 
CallableStatement stmtpro = null;
Statement stmt=null;
ResultSet rs = null;
public zjh(){
try {
   Class.forName("com.microsoft.jdbc.sqlserver.SQLServerDriver");
   conn=DriverManager.getConnection("jdbc:microsoft:sqlserver://202.118.120.236:1433;databaseName=HuaYi;user=center;password=6651002");
} catch(java.lang.SecurityException se) {
throw se;
} catch(java.lang.Exception e) {
e.printStackTrace();
}
}
//êy?Y′|àí
public ResultSet executeQuery(String sql){
stmt=null;
rs = null;
try {        
     stmt=conn.createStatement();                                                 
     rs=stmt.executeQuery(sql);
     } catch(SQLException ex){
       System.err.println("sql_data.executeUpdate:"+ex.getMessage());
     //??ê?êy?Y?aá??ó′í?ó?ò??2é?ˉ′í?ó 
                             }   
     return rs;                          
    }
//êy?Y?üD?
public int executeUpdate(String sql){
stmt=null;	
int number = 0;
try {
       stmt=conn.createStatement();    
       stmt.executeUpdate(sql);
       if (conn==null) { return -1; }
       if (stmt == null) { return -1; }
        } catch(SQLException ex){
       System.err.println("sql_data.executeUpdate:"+ex.getMessage());
       return -1;
        }
       return number;
    }
//′?′¢1y3ìμ÷ó?,·μ??±ào?
public String executeProcedure(String BHMC){
stmtpro = null;
String BH=null;
String sql=null;
sql="{ call P_NB_BH(?,?)}";
try {    
     stmtpro=conn.prepareCall(sql);                                                 
     stmtpro.setString(1,BHMC);
     stmtpro.registerOutParameter(2,Types.CHAR);
     stmtpro.executeUpdate();
     BH = stmtpro.getString(2);
     } catch(SQLException ex){
       System.err.println("sql_data.executeUpdate:"+ex.getMessage());
     //??ê?êy?Y?aá??ó′í?ó?ò??2é?ˉ′í?ó 
                             }   
     return BH;
}
//′?′¢1y3ìμ÷ó?,·μ???′éó?úμ?1???D??¢
public  boolean executeGWSP(String YGBH){
stmtpro = null;
String sql=null;
sql="{ call P_NB_GW(?)}";
try {    
     stmtpro=conn.prepareCall(sql);                                                 
     stmtpro.setString(1,YGBH);
     stmtpro.executeUpdate();
     } catch(SQLException ex){
       System.err.println("sql_data.executeUpdate:"+ex.getMessage());
     //??ê?êy?Y?aá??ó′í?ó?ò??2é?ˉ′í?ó 
       return false;
                             }   
     return true;
}
//′?′¢1y3ìμ÷ó?,·μ??±ê????
public int executeGWLZ(String GWBH){
stmtpro = null;
int BH=0;
String sql=null;
sql="{ call P_NB_LZ(?,?)}";
try {    
     stmtpro=conn.prepareCall(sql);                                                 
     stmtpro.setString(1,GWBH);
     stmtpro.registerOutParameter(2,Types.INTEGER);
     stmtpro.executeUpdate();
     BH = stmtpro.getShort(2);
     } catch(SQLException ex){
       System.err.println("sql_data.executeUpdate:"+ex.getMessage());
     //??ê?êy?Y?aá??ó′í?ó?ò??2é?ˉ′í?ó 
                             }   
     return BH;
}

//1?±?êy?Y?′£????aá??ó
public boolean close(){
try{
if(this.rs!=null){
this.rs.close();
} 
if(stmt!=null){
this.stmt.close();
}
if(stmtpro!=null){
this.stmtpro.close();
}
if(conn!=null){
this.conn.close();
}
return true;
}catch(Exception err){
return false;
}
}
public void transfer(InputStream in,String tempFileName,String sql)
{
try
{
PreparedStatement pre;
int n;
FileOutputStream o;
File f1;
RandomAccessFile random;
String fileName=null;
String houzhui=null;
byte b[]=new byte[10000];
int second=1;
String secondLine=new String();
  f1=new File("c:/tomcat/webapps/example/",tempFileName);
  o=new FileOutputStream(f1);
  while((n=in.read(b))!=-1){o.write(b,0,n);}
  o.close();
  in.close();
  random=new RandomAccessFile(f1,"r");
  secondLine=null;
  while(second<=2)
  {secondLine=random.readLine();second++;}
  int position=secondLine.lastIndexOf('\\');
  fileName=secondLine.substring(position+1,secondLine.length()-1);
  
  //int position0=fileName.lastIndexOf('.');
  //houzhui=fileName.substring(position0+1,fileName.length()); 
  random.seek(0);
  long forthEndPosition=0;
  int forth=1;
  while((n=random.readByte())!=-1&&(forth<=4))
   {
    if(n=='\n')
    {
	    forthEndPosition=random.getFilePointer();
        forth++;
	}
   }
  File f2=new File("c:/tomcat/webapps/example/",fileName);
  RandomAccessFile random2=new RandomAccessFile(f2,"rw");
  random.seek(random.length());
  long endPosition=random.getFilePointer();
  long mark=endPosition;
  int j=1;
  while((mark>=0)&&(j<=6))
 {
   mark--;
   random.seek(mark);
   n=random.readByte();
   if(n=='\n')
   {endPosition=random.getFilePointer();j++;}
 }
  random.seek(forthEndPosition);
  long startPoint=random.getFilePointer();
  while(startPoint<(endPosition-1))
 {
   n=random.readByte();
   random2.write(n);
   startPoint=random.getFilePointer();
 }
 FileInputStream inn=new FileInputStream(f2);
try
{
 pre=conn.prepareStatement(sql);
 pre.setBinaryStream(1,inn,inn.available());
 //pre.setString(1,"fsdfs");
 int number=pre.executeUpdate();
 }
catch(SQLException ex)
{
System.err.println("sql_data.executeUpdate:"+ex.getMessage());
}
 random2.close();
 random.close();
 f1.delete();
 //f2.delete();
}
catch(IOException e){}

 }
    
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -