SQL Server中的批量加载无法加载浮点值

时间:2018-12-14 08:54:57

标签: sql-server bulkinsert sqlbulkcopy mssql-jdbc

我必须将数据从一台数据库服务器传输到一台SQL Server。我正在使用SQLServerBulkCopy来做到这一点:

// connection1 is with the source system and
// connection2 is with the destination SQL Server
Statement statement = connnection1.createStatement();

ResultSet resultSet = statement.executeQuery("select * from db.table");

SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(connection2);
bulkCopy.setDestinationTableName("tableName");
bulkCopy.writeToServer(resultSet);

这样做时出现以下错误:

  

com.microsoft.sqlserver.jdbc.SQLServerException:批量复制中不支持数据类型float。

     

在com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:226)
  在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.getDestTypeFromSrcType(SQLServerBulkCopy.java:1443)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.createInsertBulkCommand(SQLServerBulkCopy.java:1464)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.sendBulkCopyCommand(SQLServerBulkCopy.java:1611)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.doInsertBulk(SQLServerBulkCopy.java:1553)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.access $ 200(SQLServerBulkCopy.java:63)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy $ 1InsertBulk.doExecute(SQLServerBulkCopy.java:705)       在com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240)       在com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.sendBulkLoadBCP(SQLServerBulkCopy.java:733)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:1669)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeResultSet(SQLServerBulkCopy.java:641)       在com.microsoft.sqlserver.jdbc.SQLServerBulkCopy.writeToServer(SQLServerBulkCopy.java:579)

总有办法解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

尝试在SSDT中创建SSIS包。或者,如果只是基本导入,则使用“导入和导出数据”工具。