Conversion ResultSet to ArrayList

For the conversion is necessary to have a data class (in this case User). We use while loop in this case. Every iteration we create a new object and insert data to them. After that we insert the object into an ArrayList. Direct conversion of ResultSet in ArrayList does not exist.

ArrayList = new ArrayList();
ResultSet rs = stmt.executeQuery("SELECT * FROM tblUsers");
while (rs.next()) {
  int id = rs.getInt("userid");
  String name = rs.getString("username");
  User user = new User(id, name);
  arrayList.add(user);
}


Posted in Java | Leave a comment

Conversion QString to Char*

Very simple example:

QString myQstring;
Char* myChar = myQstring.toAscii().data();
Posted in C/C++ | Leave a comment

Insert ArrayList to another ArrayList

To insert an ArrayList to another ArrayList will be initialized just use a common structure:

ArrayList<String> myArrayList = new ArrayList<String>(myArrayListWithContent);
Posted in Java | Leave a comment