我想使用 hsqldb 连接到远程 CSV 并将其转换为 TEXT 表。谁能指导我需要遵循的步骤?我的代码:
String url1 = "jdbc:hsqldb:file:197.161.16.16//data10//projects//2//hsqldb";
long currMilli = System.currentTimeMillis();
String tableName = "MRx" + currMilli;
final StringBuilder createTable = new StringBuilder();
final StringBuilder setDatabase = new StringBuilder();
setDatabase.append("SET DATABASE SQL SYNTAX ORA TRUE ");
createTable.append("CREATE TEXT TABLE" + " " + tableName);
createTable.append(columnNames);
final StringBuilder linkTable = new StringBuilder();
linkTable.append("SET TABLE" + " " + tableName + " SOURCE ");
linkTable.append("\"/" + "some.csv");
linkTable.append(";ignore_first=true;all_quoted=true;shutdown=true\"");
try {
conn = DriverManager.getConnection(url1, "sa", "");
stm = conn.createStatement();
stm.execute(createTable.toString());
stm.execute(linkTable.toString());
countResult = stm.executeQuery("Select count(*) from " + tableName);
int totalCount = 0;
while (countResult.next()) {
totalCount = countResult.getInt(1);
}
....................... // more code ...............
即使 CSV 有数据,该select
语句也不返回任何内容。而如果我将相同的 CSV 复制到本地系统,并连接到它并读取它,我可以获取数据吗?谁能给我任何提示我哪里出错了!