forked from microsoft/mssql-jdbc
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
854c66c
commit c482c60
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
src/test/java/com/microsoft/sqlserver/jdbc/issues/GH1554.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |