Hi guys, I need to format Phonenumbers inside Access and already got the Data and formatted all phonenumbers inside an Arraylist, now I need to update the phonenumbers with the new formatted Values but the update function does not work. While Debugging I noticed that my ResultSet seems to be empty, but reparing the AccessDatabase did not help.
publicvoidexecuteQueryPhoneNumber(StringtableName,StringcolumnName){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(SQLExceptione){System.err.println(e.getMessage()+"\nErrorCode: "+e.getErrorCode());}}
This is the working Query to get the phonenumbers
publicvoidupdatePhonenumberColumn(){try{inti=0while(this.resultSet.next()){Stringsql="UPDATE "+this.table+" SET "+this.phonenumberColumn+"=? "+" WHERE "+this.idColumnName+="=?";PreparedStatementpreparedStatement=connection.prepareStatement(sql,ResultSet.TYPE_SCROLL_INSENSITIVE,ResultSet.CONCUR_UPDATEABLE);preparedStatement.setString(1,this.phonenumbers.get(i));preparedStatement.setString(2,Integer.toString(i));preparedStatement.executeUpdat();i++;}catch(SQLExceptione){System.err.println(e.getMessage()+"\nErrorcode: "+e.getErrorCode());}}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys, I need to format Phonenumbers inside Access and already got the Data and formatted all phonenumbers inside an Arraylist, now I need to update the phonenumbers with the new formatted Values but the update function does not work. While Debugging I noticed that my ResultSet seems to be empty, but reparing the AccessDatabase did not help.
This is the working Query to get the phonenumbers
Answered on Stack Overflow.