Здравствуйте, есть код: import java.io.FileInputStream; import java.sql.*; import java.util.HashMap; import java.util.Map; import - вопрос №1973241

java.util.Properties; public class ProfilesDAOTest { private Connection myConn; public ProfilesDAOTest() throws Exception{ try { Class.forName(«com.mysql.jdbc.Driver»); Properties prop = new Properties(); prop.load(new FileInputStream(«info.properties»)); String user = prop.getProperty(«user»); String password = prop.getProperty(«password»); String dburl = prop.getProperty(«dburl»); myConn = DriverManager.getConnection(dburl, user, password); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); } return; } public void updateProfiles (HashMap theProfiles) throws DAOException{ PreparedStatement myStmt = null; String sql = «UPDATE profiles SET user_name=?, nick_name=?, user_mail=?» + ", password=?, gender=?, country=?"; try { myConn.setAutoCommit(false); myStmt = myConn.prepareStatement(sql); for (Map.Entry e: theProfiles.entrySet()) { myStmt.setString(1, String.valueOf(e.getValue().intValue())); myStmt.setString(2, String.valueOf(e.getValue().intValue())); myStmt.setString(3, String.valueOf(e.getValue().intValue())); myStmt.setString(4, String.valueOf(e.getValue().intValue())); myStmt.setString(5, String.valueOf(e.getValue().intValue())); myStmt.setString(6, String.valueOf(e.getValue().intValue())); myStmt.executeUpdate(); myConn.commit(); } } catch (SQLException e) { e.printStackTrace(); } finally { try{ if (myConn != null) { myConn.close(); } if (myStmt != null) { myStmt.close(); } } catch (SQLException e) { e.printStackTrace(); } } } }

 

 

как сделать так, чтобы Map кэшировал запрос для повторного использования?

30.05.16
0 ответов
Ответов пока нет
Посмотреть всех экспертов из раздела Технологии > Java/J2EE
Пользуйтесь нашим приложением Доступно на Google Play Загрузите в App Store