Description
Driver version
sqljdbc42.jar
SQL Server version
SQL Server 2014
Client Operating System
Windows 10
JAVA/JVM version
JDK 1.8
Table schema
I wanna just store the complete raw data directly from a text file to the corresponding columns using SQLServerBulkCopy API, so I have not kept any keys (primary/unique/foreign) for my table
Problem description
I am using SQLServerBulkCopy API to store millions of records. My app runs in websphere-liberty. I use SQLServerConnectionPoolDataSource. So when I try to pass the connection to the bulkCopy like
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(conn);
I get an exception stating
com.microsoft.sqlserver.jdbc.SQLServerException: Destination connection must be a connection from the Microsoft JDBC Driver for SQL Server.
where the conn
is unwrapped using ISQLServerConnection
interface from app server created connection namely WsJdbcConnection
.
But passing a physical connection using the connection url to the SQLServerBulkCopy works good.
Reproduction code
if(connection.isWrapperFor(ISQLServerConnection.class)) {
ISQLServerConnection conn = connection.unwrap(ISQLServerConnection.class);
SQLServerBulkCopy bulkCopy = new SQLServerBulkCopy(conn);
}
Metadata
Metadata
Assignees
Labels
Type
Projects
Status