Skip to content

Commit

Permalink
1554
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffery-Wasty committed Jul 15, 2024
1 parent 854c66c commit c482c60
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/test/java/com/microsoft/sqlserver/jdbc/issues/GH1554.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.microsoft.sqlserver.jdbc.issues;

import com.microsoft.sqlserver.jdbc.SQLServerDataSource;

import java.sql.*;


public class GH1554 {
public static void main(String[] args) throws Throwable {
SQLServerDataSource ds = new SQLServerDataSource();

String connectionUrl = "jdbc:sqlserver://localhost:1433;database=TestDb;user=sa;password=TestPassword123;" +
"encrypt=false;useBulkCopyForBatchInsert=true";
ds.setURL(connectionUrl);

Date time = new Date(2024,10,12);
Connection c = ds.getConnection();
PreparedStatement ps;
ResultSet rs;
try {
c.setAutoCommit(false);
String sql = "INSERT INTO testTable (c1, c2, c3) VALUES (?,?,?)";
ps = c.prepareStatement(sql);
try {
ps.setInt(1, 1);
ps.setString(2, "123");
ps.setDate(3, time);
ps.addBatch();
ps.executeBatch();
c.commit();
} finally {
ps.close();
}
} catch (Throwable t) {
throw t;
}
}
}

0 comments on commit c482c60

Please sign in to comment.