我现在正在做导出数据的功能,用的是sql server数据库
想把数据导出成mdb格式,就是access数据库
在生成列字段的时候,普通字符串都是用的field.setSQLType(Types.VARCHAR);
问题就在这了,我在sql server里有text类型的列,用Types.VARCHAR存放不下了
我试了用别的都不行啊,有的运行错误,我用Types.LONGVARCHAR还出了运行环境错误
不知道有没有人遇到过这样的情况
希望有人帮我解决一下这个问题 急啊!
先谢谢各位高手了!

解决方案 »

  1.   

    大于256个字符的,用Memo数据类型。
      

  2.   

    不行啊,Types.里怎么有Memo的类型啊
    你是怎么解决的啊
      

  3.   

    Types能.出来text吗,我的怎么没有text类型呢
    还有用Types.CLOB就会出现这个错误
    java.sql.SQLException: Unsupported SQL type: 2005
    at com.healthetscience.jackcess.DataType.fromSQLType(DataType.java:248)
    at com.healthetscience.jackcess.Column.setSQLType(Column.java:195)
    at hz.infos.action.nirmcaction.PnlExportAction.createMdb(PnlExportAction.java:575)
    at hz.infos.action.nirmcaction.PnlExportAction.access$200(PnlExportAction.java:56)
    at hz.infos.action.nirmcaction.PnlExportAction$3.run(PnlExportAction.java:350)能说的具体点吗  谢谢啊
      

  4.   

    理解错了。我以为lz用Hibernate。
    SQL Server 可以用text类型。
      

  5.   

    不好意思。lz是想从sql server导出数据到access中去,这样access中应该用
    Memo类型了。
      

  6.   

    你还是理解错了啊  呵呵 
    我说的是要导出成mdb格式的  就是导出成access
    就是这段代码 你看看是哪的错误
    Vector fields = new Vector();
    Column field = new Column();
    field.setName("备注");
    field.setSQLType(Types.VARCHAR);
    fields.addElement(field);
    db.createTable(fileName, fields);
    就是field.setSQLType(Types.VARCHAR)这里,这个用的是普通的字符串
    就像sql server里的text那样的类型  我这里应该怎么设置呢
    不知道你这回明白我的意思没
      

  7.   


    这个我也用过了   不过出了个这样的问题
    运行环境错误  直接退出程序了
    #
    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x05eee4d4, pid=800, tid=3744
    #
    # JRE version: 6.0_14-b08
    # Java VM: Java HotSpot(TM) Client VM (14.0-b16 mixed mode, sharing windows-x86 )
    # Problematic frame:
    # C  [msjet40.dll+0xe4d4]
    #
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.
    #这是什么原因呢?
      

  8.   

    如果sql server用text类型,java JDBC应该用LONGVARCHAR;
    如果是ntext类型,就要用LONGNVARCHAR。不过,不可以调用update<LONGVARCHAR>,update<LONGNVARCHAR> 和updateObject<int,LONGVARCHAR>,updateObject<int,LONGNVARCHAR> 方法,
    你可以检查一下有没有这种情况。
      

  9.   

    这是我写的核心代码你帮我看看是哪个环节不对呢,谢谢了
    //连接access
    Database db = Database.create(new File(filePath));
    //所有字段名
    Vector fields = new Vector();
    //列
    Column field = new Column();
    //设置列名
    field.setName('备注');
    //设置列类型
    field.setSQLType(Types.LONGVARCHAR);
    //添加到列向量
    fields.addElement(field);
    //创建表
    db.createTable(fileName, fields);
    //获取表名
    Table newTable = db.getTable(fileName);
    String tableName = newTable.getName();
    //连接
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:odbc:driver={Microsoft Access Driver (*.mdb)};DBQ=" + filePath);
    Statement statement = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    //组成insert语句
    String sql = "";
    //执行语句
    statement.executeUpdate(insertSql);这段就是我导出access的主要代码,是我的方法有问题吗?
      

  10.   

    这句
    Statement statement = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);
    换成
    Statement statement = con.createStatement();
      

  11.   


    不行啊,还是运行环境出错直接退出了
    #
    # A fatal error has been detected by the Java Runtime Environment:
    #
    #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x05f8e4d4, pid=1584, tid=2872
    #
    # JRE version: 6.0_14-b08
    # Java VM: Java HotSpot(TM) Client VM (14.0-b16 mixed mode, sharing windows-x86 )
    # Problematic frame:
    # C  [msjet40.dll+0xe4d4]
    #
    # If you would like to submit a bug report, please visit:
    #   http://java.sun.com/webapps/bugreport/crash.jsp
    # The crash happened outside the Java Virtual Machine in native code.
    # See problematic frame for where to report the bug.
    #
    唉  我要崩溃了