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

📄 webprint.java

📁 一个完整的
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	//java.sql.Blob myBlob     = null;
    java.sql.Clob myClob     = null;
    java.sql.Clob myClob1     = null;
	  // set Oracle's Auto Commit feature to false. 
	  // This is necessary when manipulating Blobs and Clobs.
//	CallableStatement cstmt=null;
	try {
		  con.setAutoCommit(false);
		  Statement stmt = con.createStatement();
	      stmt.execute("insert into fccell values ('"+strName+"',EMPTY_CLOB(),EMPTY_CLOB(),null)");
      // ============== Manipulating the Clob column ======================
      // get a reference to the clob column
      stmt.execute("select * from fccell where fstrtablename='"+strName+"'");
      ResultSet crs = stmt.getResultSet();
      while ( crs.next() ) {
          myClob = crs.getClob("fstrtable");

          java.io.OutputStream osss =
              ((weblogic.jdbc.common.OracleClob) myClob).getAsciiOutputStream();
          byte[] bss = strTable.getBytes("ASCII");
          osss.write(bss);
          osss.flush();


          myClob1 = crs.getClob("fstrtable1");
          
          java.io.OutputStream osss1 =
              ((weblogic.jdbc.common.OracleClob) myClob1).getAsciiOutputStream();
          byte[] bss1 = strTable1.getBytes("ASCII");
          osss1.write(bss);
          osss1.flush();

      }
      con.commit();
      
      // read back the clob
      //System.out.println("\nReading the clob back from the table and displaying:");

	}
	catch (Exception e){
		e.printStackTrace();
		sTmp=e.getMessage() ;
	}
	
	return sTmp ;

}
//--------------------------------------
private String fc_updateClob() {
	Node root = document.getChildNodes().item(0);
    String strName=root.getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
    String strTable=root.getChildNodes().item(1).getChildNodes().item(0).getNodeValue();
    String strTable1=root.getChildNodes().item(2).getChildNodes().item(0).getNodeValue();
	String sTmp = "";
	//System.out.println("1:"+strSql) ;
	//java.sql.Blob myBlob     = null;
    java.sql.Clob myClob     = null;
    java.sql.Clob myClob1     = null;
	  // set Oracle's Auto Commit feature to false. 
	  // This is necessary when manipulating Blobs and Clobs.
//	CallableStatement cstmt=null;
	try {
		//con.setAutoCommit(false);			
		  Statement stmt = con.createStatement();
		  //System.out.println("删除成功!"+strName);
	      stmt.executeUpdate("delete from fccell where fstrTableName='"+strName+"'");
		//con.commit();
		  //if (1==1){
          //  stmt.close();
          //  return "";
           //}
		  
		  con.setAutoCommit(false);
		  stmt = con.createStatement();
	      //stmt.executeUpdate("delete from fccell where fstrTableName='"+strName+"'");
		  //System.out.println("删除成功!");
          
		  stmt.execute("insert into fccell values ('"+strName+"',EMPTY_CLOB(),EMPTY_CLOB(),null)");
		  //stmt.execute("update fccell set fstrtablename='"+strName+"',fstrtable=EMPTY_CLOB(),fstrtable1=EMPTY_CLOB() where fstrtableName='"+strName+"'");
      // ============== Manipulating the Clob column ======================
      // get a reference to the clob column
      stmt.execute("select * from fccell where fstrtablename='"+strName+"'");
      ResultSet crs = stmt.getResultSet();
      while ( crs.next() ) {

          myClob = crs.getClob("fstrtable");

          java.io.OutputStream osss =
              ((weblogic.jdbc.common.OracleClob) myClob).getAsciiOutputStream();
          byte[] bss = strTable.getBytes("ASCII");
          osss.write(bss);
          osss.flush();


          myClob1 = crs.getClob("fstrtable1");
          
          java.io.OutputStream osss1 =
              ((weblogic.jdbc.common.OracleClob) myClob1).getAsciiOutputStream();
          byte[] bss1 = strTable1.getBytes("ASCII");
          osss1.write(bss1);
          osss1.flush();

      }
      con.commit();
      
      // read back the clob
      //System.out.println("\nReading the clob back from the table and displaying:");

	}
	catch (Exception e){
		e.printStackTrace();
		sTmp=e.getMessage() ;
	}
	
	return sTmp ;

}
//--------------------------------------
private String fc_loadClob() {
	Node root = document.getChildNodes().item(0);
    String strName=root.getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
	String sTmp = "";
	//System.out.println("1:"+strSql) ;
	//java.sql.Blob myBlob     = null;
    java.sql.Clob myClob     = null;
    java.sql.Clob myClob1     = null;
	  // set Oracle's Auto Commit feature to false. 
	  // This is necessary when manipulating Blobs and Clobs.
//	CallableStatement cstmt=null;
	try {
      Statement readclob = con.createStatement();
      readclob.execute("select * from fccell where fstrtablename='"+strName+"'");
      ResultSet rsreadclob = readclob.getResultSet();
            
      // read the clob in as and ASCII stream, write to a character array, and display
      String sTest="";
      while ( rsreadclob.next() ) { 
          Clob myReadClob =rsreadclob.getClob("fstrtable");    
          /*
          //java.io.InputStream readClobis = myReadClob.getAsciiStream();
          java.io.InputStream readClobis = myReadClob.getCharacterStream();
          //sTest=(char)readClobis.read();
          //char[] c = new char[260];
          System.out.println("123:") ;
          int iTmp=0;
          while (iTmp!=-1) {
                iTmp=readClobis.read();
           	//	sTest+= (char) iTmp;
        	  sTest+=iTmp;
          }
          */
          int iLen=1;
          iLen=(int)myReadClob.length();
          sTest=myReadClob.getSubString(1,iLen);
              //System.out.println("output " +sTest );
              sTmp=sTest;
      }        

	}
	catch (Exception e){
		e.printStackTrace();
		sTmp=e.getMessage() ;
	}
	
	return sTmp ;

}
//--------------------------------------
private String fc_loadClob1() {
//为了取另外一个备注字段值fstrTable1	
	Node root = document.getChildNodes().item(0);
    String strName=root.getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
	String sTmp = "";
	//System.out.println("1:"+strSql) ;
	//java.sql.Blob myBlob     = null;
    java.sql.Clob myClob     = null;
    java.sql.Clob myClob1     = null;
	  // set Oracle's Auto Commit feature to false. 
	  // This is necessary when manipulating Blobs and Clobs.
//	CallableStatement cstmt=null;
	try {
      Statement readclob = con.createStatement();
      readclob.execute("select * from fccell where fstrtablename='"+strName+"'");
      ResultSet rsreadclob = readclob.getResultSet();
            
      // read the clob in as and ASCII stream, write to a character array, and display
      String sTest="";
      String sTest1="";
      while ( rsreadclob.next() ) { 
          Clob myReadClob =rsreadclob.getClob("fstrtable1");    
          /*
          //java.io.InputStream readClobis = myReadClob.getAsciiStream();
          java.io.InputStream readClobis = myReadClob.getCharacterStream();
          //sTest=(char)readClobis.read();
          //char[] c = new char[260];
          System.out.println("123:") ;
          int iTmp=0;
          while (iTmp!=-1) {
                iTmp=readClobis.read();
           	//	sTest+= (char) iTmp;
        	  sTest+=iTmp;
          }
          */
          int iLen=1;
          iLen=(int)myReadClob.length();
          sTest=myReadClob.getSubString(1,iLen);
		  sTmp=sTest;	
              //System.out.println("output " +sTest );
          /*
          Clob myReadClob1 =rsreadclob.getClob("fstrtable1");    
          iLen=(int)myReadClob1.length();
          sTest1=myReadClob1.getSubString(1,iLen);


          sTmp="<no>"+sTest+"</no><no1>"+sTest1+"</no1>";
*/

      }        

	}
	catch (Exception e){
		e.printStackTrace();
		sTmp=e.getMessage() ;
	}
	
	return sTmp ;

}

//--------------------------------------
private String fc_insert() {
	Node root = document.getChildNodes().item(0);
    String strSql=root.getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
	strSql=fcTrans(strSql);
	String sTmp = "";
//	CallableStatement cstmt=null;
	try {
		Statement stmt = con.createStatement();
//		stmt.executeQuery(strSql);
		
		stmt.executeUpdate(strSql);
/*
		cstmt=con.prepareCall("{call sp_getID(?)}");
		cstmt.registerOutParameter(1,java.sql.Types.INTEGER,1);
		cstmt.executeUpdate();
		sTmp="<dsnID>"+ cstmt.getInt(1)+"</dsnID>";
*/
	}
	catch (Exception e){
		e.printStackTrace();
		sTmp=e.getMessage() ;
	}
	
	return sTmp ;

}

//--------------------------------------
private String fc_insert1() {
//凭证增加
	Node root = document.getChildNodes().item(0);
	String sTmp = "";
	CallableStatement cstmt=null;
	try {
		Statement stmt = con.createStatement();
		int i;
		//System.out.println(root.getChildNodes().getLength());
	    String strSql=root.getChildNodes().item(0).getChildNodes().item(0).getNodeValue();
		strSql=fcTrans(strSql);
		stmt.executeUpdate(strSql);
		
		String sID="1"; //存主表新生成的ID
		
		try {
			//SQL Server 的存储过程,用于计算自动ID
			cstmt=con.prepareCall("{call sp_getID(?)}");
			cstmt.registerOutParameter(1,java.sql.Types.INTEGER,1);
			cstmt.executeUpdate();
			sID=""+cstmt.getInt(1);
		}
		catch (Exception e1){
			try {
				//计算MS Access数据库的主表ID
				String sDBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"; 
				String sConnStr = "jdbc:odbc:webprint"; 
				Class.forName(sDBDriver);
				Connection con1 = DriverManager.getConnection(sConnStr,"sa",""); 
				Statement stmt1 = con1.createStatement();
				rs1 = stmt1.executeQuery("select max(flngSendOutID) From SendOut");
				if (rs1.next()) {
					sID=rs1.getString(1);
				}
			}
			catch (Exception e2){
			}
		}

		//追加子表内容
		for(i=1;i<root.getChildNodes().getLength();i++) {
		    strSql=root.getChildNodes().item(i).getChildNodes().item(0).getNodeValue();
			strSql=fcTrans(strSql);
			strSql=strSql+sID+" )";
			stmt.executeUpdate(strSql);
		}

	}
	catch (Exception e){
		System.out.println(e.getMessage()) ;
	}
	
	return sTmp ;

}
//--------------------------------------
private String fc_update1() {
//凭证修改
	Node root = document.getChildNodes().item(0);
	String sTmp = "";
	String strSql="";
	try {
		Statement stmt = con.createStatement();
		int i;

		for(i=0;i<root.getChildNodes().getLength();i++) {
		    strSql=root.getChildNodes().item(i).getChildNodes().item(0).getNodeValue();
			strSql=fcTrans(strSql);
			stmt.executeUpdate(strSql);
		}

	}
	catch (Exception e){
		System.out.println(e.getMessage()) ;
	}
	
	return sTmp ;

}
//--------------------------------------
private String SqlToField(String strSql) {
//用一个SQL语句返回一个字段的第一个记录值
	String strR =  "";
	try {
		Statement stmt = con.createStatement();
		rs = stmt.executeQuery(strSql);
		if (rs.next()) {
		    strR = rs.getString(1) ;
		}
		rs.close();
		stmt.close();
	}
	catch (Exception e){
			//out.println("读表发生错误");
		}
	return strR;

}
//--------------------------------------
//报表增加
//--------------------------------------

⌨️ 快捷键说明

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