0
我需要製作一個Jar來從Access數據庫中格式化電子表格,並使用UcanAccess進行此操作,所有查詢都可以正常工作,直到我需要使用格式化的phonenumbers。UcanAccess ::: 4.0.2意外的令牌:164更新查詢
public void updatePhonenumberColumn()
{
try {
for (int i = 0; i < this.phoneNumbers.size(); i++) {
String SQL = "UPDATE [" + this.table + "] SET [" + this.phonenumberColumn + "]=" + this.phoneNumbers.get(i) + " WHERE [" + this.id + "]=" + i;
PreparedStatement preparedStatement = connection.prepareStatement(SQL);
preparedStatement.executeUpdate();
}
} catch (SQLException e) {
System.err.println(e.getMessage() + "\nErrorcode: " + e.getErrorCode());
}
}
我一直在使用括號作爲其他職位建議試過了,格式化PHONENUMBERS存儲在由自己一個ArrayList,然後我嘗試使用更新語句添加。如果不清楚,我會盡力提供更多信息。
我已經嘗試過使用ResultSet.next(),並注意到while循環立即留下,就好像ResultSet將是空的,這是不可能的,因爲我之前使用完全相同的代碼將phonenumbers附加到我的ArrayList中。
public void updatePhonenumberColumn()
{
String sql = "SELECT " + this.phonenumberColumn + " FROM " + this.table;
try {
Statement statement = connection.createStatement();
this.resultSet = statement.executeQuery(sql);
System.out.println(this.resultSet.getFetchSize());
} catch (SQLException e) {
System.err.println(e.getMessage() + "\nErrorcode: " + e.getErrorCode());
}
}
低於早前的查詢來獲得PHONENUMBERS了Access數據庫
public void executeQueryPhoneNumber(String tableName, String columnName)
{
this.actualColumn = columnName;
this.phonenumberColumn = columnName;
this.table = tableName;
try {
this.query = this.connection.createStatement();
this.resultSet = query.executeQuery("SELECT " + this.phonenumberColumn + " FROM " + this.table);
appendItems(this.phoneNumbers, this.resultSet);
} catch (SQLException e) {
System.err.println(e.getMessage() + "\nErrorCode: " + e.getErrorCode());
}
}
我將不勝感激任何想法非常多的