请问在jxl包或poi包中是否有一个会识别cell(col,row)中为空的方法,当cell(col,row)
  为空时就出现一个判断标志,以判断标志去控制程序不去读取空单元格,接着去读取下
  一个单元个数据直到程序运行完?如果没有,怎样才能实现我的这种问题? 
 我的QQ:380462843  Email:[email protected]

解决方案 »

  1.   

    Hibernate在处理数据录入的时候,会把最近插入的对象以session-level cache在内存做缓存,但是它没有限制这个缓存的大小,我们可以这样做:
    你先设置一个合理的JDBC批处理大小,hibernate.jdbc.batch_size 20,然后在一定间隔对Session进行flush()和clear()。
    Session session = sessionFactory.openSession();
    Transaction tx = session.beginTransaction();
    for ( int i=0; i<100000; i++ ) {
      Customer customer = new Customer(.....);
      session.save(customer);
      if ( i % 20 == 0 ) {
        //flush 插入数据和释放内存: session.flush(); session.clear();
      }
    }
    tx.commit();
    session.close();注意,如果当前要录入操作的对象启用了second-level caching,我们仍然会有一些内存管理的问题。原因就是对于用户的每一次插入和更新,Hibernate在事务处理结束后不得不通告second-level cache .因此,我们在批处理情况下必须禁用用户使用缓存
      

  2.   

    在网上找到了以下的例子:
    但在运行时却出现如下的错误:
    先是:
    java.sql.SQLException: 无效的名称模式 ....
    然后我在ORACLE的用户类型里面添加了一个用户类型,
    然后又出现:
    java.sql.SQLException: Non supported character set: oracle-character-set-850
            at oracle.gss.util.NLSError.throwSQLException(NLSError.java:46)
            at oracle.sql.CharacterSetUnknown.failCharsetUnknown(CharacterSetFactoryThin.java:171)
    怎样解决啊?急------------------------------
    不用导文件的方式,因为用sqlldr导数据,主键是一个序列,这样就不能用direct=true的方式来倒,而且表不为空时也不能用direct=true的方式,只能用普通方式倒,30000条耗时>;30秒,这样比较慢,不满足要求。我计划用java的batch insert方式来做,但时间也不理想。计划用java  array insert 来做。具体代码:    oracle.sql.ARRAY ora_array1=null,ora_array2=null,ora_array3=null,ora_array4=null;    try {
          oradb.beginConnect();      oradb.conn.setAutoCommit(false); // If some fail, we want to rollback the rest
          PreparedStatement stmt = oradb.conn.prepareStatement(
              "INSERT INTO product_tmp VALUES (?,?,?,?)";      try {
            // Create an oracle.sql.ARRAY object to hold the values
    //      java.lang.Stringname
            oracle.sql.ArrayDescriptor arrayDesc1 =
                oracle.sql.ArrayDescriptor.createDescriptor("number_array",
                oradb.conn);
            oracle.sql.ArrayDescriptor arrayDesc2 =
                oracle.sql.ArrayDescriptor.createDescriptor("string_array",
                oradb.conn);
            oracle.sql.ArrayDescriptor arrayDesc3 =
                oracle.sql.ArrayDescriptor.createDescriptor("string_array",
                oradb.conn);
            oracle.sql.ArrayDescriptor arrayDesc4 =
                oracle.sql.ArrayDescriptor.createDescriptor("STRING_ARRAY",
                oradb.conn);        int array1[] = new int[30000];
            String array2[] = new String[30000];
            String array3[] = new String[30000];
            String array4[] = new String[30000];
            Array t[] = new Array[30000];
            for (int i = 0; i < 30000; i++) {
              array1 = 444;
              array2 = "115S0003A";
              array3 = "ic";
              array4 = "136";
            }
            ora_array1 = new oracle.sql.ARRAY(arrayDesc1, oradb.conn, array1);
            ora_array2 = new oracle.sql.ARRAY(arrayDesc2, oradb.conn, array2);
            ora_array3 = new oracle.sql.ARRAY(arrayDesc3, oradb.conn, array3);
            ora_array4 = new oracle.sql.ARRAY(arrayDesc4, oradb.conn, array4);      }
          catch (Exception ex) {
            ex.printStackTrace(out);
          }      stmt.setArray(1, ora_array1);
          stmt.setArray(2, ora_array2);
          stmt.setArray(3, ora_array3);
          stmt.setArray(4, ora_array4);
          /*
                 stmt.setInt(1,333);
                 stmt.setString(2, "115S0003A";
                 stmt.setString(3, "ic";
                 stmt.setString(4, "136";
                 stmt.addBatch(  );
                 stmt.setInt(1,333);
                 stmt.setString(2, "115S0003A";
                 stmt.setString(3, "ic";
                 stmt.setString(4, "136";
           */
          stmt.addBatch();      int[] upCounts = stmt.executeBatch();
          oradb.conn.commit();    }
        catch (Exception ex) {
        }
        oradb.closeConnection();
    这里有几篇参考资料:
    http://archives.postgresql.org/pgsql-jdbc/2003-07/msg00179.php
    http://jakarta.apache.org/commons/dbutils/xref/org/apache/commons/dbutils/QueryRunner.html
    http://javaalmanac.com/egs/java.sql/BatchUpdate.html
    http://javaalmanac.com/egs/java.sql/CanBatch.html
    http://javaalmanac.com/egs/java.sql/InsertArrayPs.html
    http://www.zdnet.com.cn/developer/code/story/0,2000081534,39224104,00.htm
    http://asktom.oracle.com/pls/ask/f?p=4950:8:::::F4950_P8_DISPLAYID:8908169959941 ----------------------------
      

  3.   

    不用这么麻烦吧?而且这种做法也不使用Hibernate啊
      

  4.   

    批量插入的话还是用JDBC非要用hibernate,就是如javapassion(村长赵大宝)所说,设定batch_size 和定时清空session
      

  5.   

    我现在是使用JDBC连接了,,出现:
    java.sql.SQLException: Non supported character set: oracle-character-set-850怎样解决啊?
    找了资料,,说要在 LIB目录下加nls_charset12.jar,我也加了,还是一样的错误!!!
    纳闷