At com. Microsoft. Essentially. JDBC. SQLServerException. MakeFromDatabaseError (SQLServerException. Java: 258)
At com. Microsoft. Essentially. JDBC. TDSTokenHandler. OnEOF (tdsparser. Java: 256)
At com. Microsoft. Essentially. JDBC. TDSParser. Parse (TDSParser. Java: 108)
At com. Microsoft. Essentially. JDBC. TDSParser. Parse (28) TDSParser. Java:
At com. Microsoft. Essentially. JDBC. SQLServerBulkCopy. DoInsertBulk (SQLServerBulkCopy. Java: 1611)
At com. Microsoft. Essentially. JDBC. SQLServerBulkCopy. Access the $200 (SQLServerBulkCopy. Java: 58)
At com. Microsoft. Essentially. JDBC. SQLServerBulkCopy $1 insertbulk. The doExecute (SQLServerBulkCopy. Java: 709)
At com. Microsoft. Essentially. JDBC. TDSCommand. Execute (IOBuffer. Java: 7151)
At com. Microsoft. Essentially. JDBC. SQLServerConnection. ExecuteCommand (SQLServerConnection. Java: 2478)
At com. Microsoft. Essentially. JDBC. SQLServerBulkCopy. SendBulkLoadBCP (SQLServerBulkCopy. Java: 739)
At com. Microsoft. Essentially. JDBC. SQLServerBulkCopy. WriteToServer (SQLServerBulkCopy. Java: 1684)
At com. Microsoft. Essentially. JDBC. SQLServerBulkCopy. WriteResultSet (SQLServerBulkCopy. Java: 645)
At com. Microsoft. Essentially. JDBC. SQLServerBulkCopy. WriteToServer (SQLServerBulkCopy. Java: 594)
At com. Miextreme. Test. Essentially. Task. WriteTask. InsertBatch (WriteTask. Java: 284)
At com. Miextreme. Test. Essentially. Task. WriteTask. Run (154) WriteTask. Java:
Java code is as follows:
Private the CachedRowSetImpl getCachedRowSet () throws SQLException {
The Connection Connection=instance. GetConnection ();
PreparedStatement prepareStatement=connection. PrepareStatement (" SELECT * FROM [cfa_personbase_info] WHERE 1=0 ");
The ResultSet targetTableResultSet=prepareStatement. ExecuteQuery ();
The CachedRowSetImpl cachedRowSet=new the CachedRowSetImpl ();
CachedRowSet. The populate (targetTableResultSet);
If (prepareStatement!=null) {
PrepareStatement. Close ();
PrepareStatement=null;
}
If (connection!=null) {
Connection. The close ();
The connection=null;
}
Return the cachedRowSet;
}
Private void insertIntoCachedRowSet (the CachedRowSetImpl cachedRowSet Map
//move the pointer to "insert row"
CachedRowSet. MoveToInsertRow ();
//insert row
Set
Iterator
While (columnIterator. HasNext ()) {
String columnName=columnIterator. Next ();
The Object columnValue=https://bbs.csdn.net/topics/rowData.get (columnName);
If (columnValue=null https://bbs.csdn.net/topics/={
CachedRowSet. UpdateNull (columnName);
} else {
CachedRowSet. UpdateObject (columnName, columnValue);
}
}
CachedRowSet. InsertRow ();
//move the pointer to the current line
CachedRowSet. MoveToCurrentRow ();
}
Private void insertBatch (the CachedRowSetImpl cachedRowSet, int batchSize) throws SQLException {
//target source URL
StringBuffer connectionUrl=new StringBuffer (" JDBC: essentially://127.0.0.1:1433; DatabaseName=tar_test; User=sa; Password=sa ");
//BulkCopyOptions
SQLServerBulkCopyOptions copyOptions=new SQLServerBulkCopyOptions ();
CopyOptions. SetKeepIdentity (true);
CopyOptions. SetBatchSize (batchSize);
CopyOptions. SetUseInternalTransaction (true);
CopyOptions. SetBulkCopyTimeout (3600);
//BulkCopy
SQLServerBulkCopy bulkCopy=new SQLServerBulkCopy (connectionUrl. ToString ());
BulkCopy. SetBulkCopyOptions (copyOptions);
BulkCopy. SetDestinationTableName (" [cfa_personbase_info] ");
BulkCopy. AddColumnMapping (" personid ", personid "");
BulkCopy. AddColumnMapping (" gonghao ", "gonghao");
BulkCopy. AddColumnMapping (" name ", "name");
BulkCopy. AddColumnMapping (" cardtype ", "cardtype");
BulkCopy. AddColumnMapping (" cardid ", cardid "");
BulkCopy. AddColumnMapping (" birthday ", "birthday");
BulkCopy. AddColumnMapping (" sex ", "sex");
BulkCopy. AddColumnMapping (" getjobtime ", "getjobtime");
BulkCopy. AddColumnMapping (" workingyears ", "workingyears");
BulkCopy. AddColumnMapping (" nationlity, "" nationlity");
BulkCopy. AddColumnMapping (" for "and" for ");
BulkCopy. AddColumnMapping (" nation ", "nation");
BulkCopy. AddColumnMapping (" polity, "" polity");
BulkCopy. AddColumnMapping (" foreignlang ", "foreignlang");
BulkCopy. AddColumnMapping (" highestdegree ", "highestdegree");
BulkCopy. AddColumnMapping (" highstudy ", "highstudy");
BulkCopy. AddColumnMapping (" technicrank ", "technicrank");
BulkCopy. AddColumnMapping (" address ", "address");
BulkCopy. AddColumnMapping (" postcode ", "postcode");
BulkCopy. AddColumnMapping (" telephone ", "telephone");
BulkCopy. AddColumnMapping (" cellphone ", "cellphone");
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull