src/test/java/org/embulk/output/sqlserver/SQLServerTests.java in embulk-output-sqlserver-0.8.5 vs src/test/java/org/embulk/output/sqlserver/SQLServerTests.java in embulk-output-sqlserver-0.8.6
- old
+ new
@@ -35,11 +35,11 @@
String password = config.get(String.class, "password");
String host = config.get(String.class, "host");
Integer port = config.get(Integer.class, "port");
String database = config.get(String.class, "database");
- String url = String.format("jdbc:jtds:sqlserver://%s:%d/%s", host, port, database);
+ String url = String.format("jdbc:sqlserver://%s:%d;databaseName=%s", host, port, database);
return DriverManager.getConnection(url, user, password);
}
public static void execute(String sql, String... options)
@@ -78,14 +78,19 @@
}
}
public static String selectRecords(TestingEmbulk embulk, String tableName) throws IOException
{
+ return executeQuery(embulk, "SELECT * FROM " + tableName);
+ }
+
+ public static String executeQuery(TestingEmbulk embulk, String query) throws IOException
+ {
Path temp = embulk.createTempFile("txt");
Files.delete(temp);
// should not use UTF8 because of BOM
- execute("SET NOCOUNT ON; SELECT * FROM " + tableName, "-h", "-1", "-s", ",", "-W", "-f", "932", "-o", temp.toString());
+ execute("SET NOCOUNT ON; " + query, "-h", "-1", "-s", ",", "-W", "-f", "932", "-o", temp.toString());
List<String> lines = Files.readAllLines(temp, Charset.forName("MS932"));
Collections.sort(lines);
StringBuilder sb = new StringBuilder();
for (String line : lines) {