how i create a connector that contains an mysql query and the result be saved in java.lang.long variable?

1
0
-1

Hi evrybody,

i have this code that allow to retrieve the "id" and "name" of user, but the results are stored in java.util.HashMap variable , i just want to store the results into java.lang.long variable instead of java.utilHashMap.

the code is:

HashMap<String,String> hm= new HashMap<String,String>();

resultset.beforeFirst();
while (resultset.next()) {
String nom = resultset.getString('userName');
String id = resultset.getString('id');
hm.put(id,name);
}
return hm;

Regards

Comments

Submitted by yannick.lombardi on Wed, 09/16/2015 - 17:32

resultset.beforeFirst();
Long id = null;
if (resultset.next()) {
id = resultset.getLong('id');
}
return id;

It returns the first id if you have a result and it returns null instead.

Submitted by claz08 on Wed, 09/16/2015 - 19:18

Thank you so much yannick :)
¿have you got a good groovy manual to try learn?

Submitted by yannick.lombardi on Thu, 09/17/2015 - 10:18

I don't use Groovy. This code is java.

Submitted by Sean McP on Fri, 09/18/2015 - 13:37

Groovy is here:
http://www.groovy-lang.org/

there are links there for books etc.

regards

No answers yet.
Notifications