Я получаю данные с листа XLS , используя jdbc sql .Ниже приведена моя программа.
Дело 1:
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc:odbc:Excel Files", "", "" );
stmnt = c.createStatement();
String query = "select * from [Proficiency$];";
ResultSet rs = stmnt.executeQuery( query );
baseColumnList = new ArrayList();
while( rs.next()) {
//baseColumnList.add(rs.getString(1));
System.out.println(rs.getString(1));
//System.out.println(baseColumnList);
}
Вывод:
Aadmin
Badmin
Badminimage
batch
Cadmin
Dadmin
Eadmin
rulesengine
Fadmin
genadmin
Gadmin
Hdomain-EU
Padmin
IAA
Дело 2:
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
c = DriverManager.getConnection( "jdbc:odbc:Excel Files", "", "" );
stmnt = c.createStatement();
String query = "select * from [Proficiency$];";
ResultSet rs = stmnt.executeQuery( query );
baseColumnList = new ArrayList();
while( rs.next()) {
baseColumnList.add(rs.getString(1));
System.out.println(baseColumnList);
}
Вывод:
[Aadmin]
[Aadmin, Badmin]
[Aadmin, Badmin, Badminimage]
[Aadmin, Badmin, Badminimage, batch]
[Aadmin, Badmin, Badminimage, batch, Cadmin]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin, rulesengine]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin, rulesengine, Fadmin]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin, rulesengine, Fadmin, genadmin]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin, rulesengine, Fadmin, genadmin, Gadmin]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin, rulesengine, Fadmin, genadmin, Gadmin, Hadmin-EU]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin, rulesengine, Fadmin, genadmin, Gadmin, Hadmin-EU, Padmin]
[Aadmin, Badmin, Badminimage, batch, Cadmin, Dadmin, Eadmin, rulesengine, Fadmin, genadmin, Gadmin, Hadmin-EU, Padmin, IAA]
Пожалуйста, кто-нибудь может объяснить, почему arraylist ведет себя странно.
Обновление: ожидаемый результат - первый вывод.