我是杰克塞斯的新手。我必须在Jackcess的帮助下从数据库中选择一列,然后将该列的值放入数组中。
在杰克塞斯的帮助下,我如何做到这一点?
发布于 2013-10-19 20:36:20
以下代码检索库存表中每一行的SerialNumber字段,并将其存储在String[]数组中:
import java.io.File;
import java.io.IOException;
import com.healthmarketscience.jackcess.*;
public class jackcessTest {
public static void main(String[] args) {
try {
Table table = DatabaseBuilder.open(new File("C:\\Users\\Public\\Database1.accdb")).getTable("Inventory");
int numRows = table.getRowCount();
String[] strArray = new String[numRows];
int index = 0;
for (Row row : table) {
strArray[index++] = row.get("SerialNumber").toString();
}
System.out.println("The first item in the array is: " + strArray[0]);
System.out.println("The last item in the array is: " + strArray[numRows - 1]);
} catch (Exception e) {
e.printStackTrace();
}
}
}发布于 2015-08-13 03:45:46
您可以使用这个库:基于https://github.com/amgohan/jackcess-orm的基于ORM的ORM,它与jackcess兼容。
https://stackoverflow.com/questions/19463852
复制相似问题