The idea is as follows, I do a resultset and get a result, I need to convert this result to integer.
The idea is as follows, I make a query at BD to know how much elements have a particular column and wanted the result in a variable of type int, to do?
Convert a ResultSet
-
- Moderador
- Posts: 1396
- Joined: Fri, 01 Feb 2008 2:06 pm
- Location: Rio de Janeiro - RJ
- Contact:
And only you do ...
ResultSet rs = cod.executeQuery("select count(coluna) as counter from tabela");
if (rs.next()) {
int contador = rs.getInt("counter");
}
Your suggestion is capable of functioning in the case of int
Suppose I have the following table:
and I want to know the name that is associated with the Code X, I do a and then as I step on this information for string.
Thanks.
Suppose I have the following table:
codigo | nome | saldo
ResultSet rs = st.executeQuery("Select nome for tabela where codigo = x");
Thanks.
-
- Moderador
- Posts: 1396
- Joined: Fri, 01 Feb 2008 2:06 pm
- Location: Rio de Janeiro - RJ
- Contact:
You spoke of int now string .. what do you want?
The interface [url=http://java.sun.com/j2se/1.4.2/docs/api ... ltSet.html]ResultSet of Java has all the necessary methods to pick up the various types of data, including blob ..
Do you want string? ... use
...
if you want to boost your query you will have to use [url=http://java.sun.com/j2se/1.4.2/docs/api ... ement.html]PreparedStatement and start do an executeQuery () to get a resulse
The interface [url=http://java.sun.com/j2se/1.4.2/docs/api ... ltSet.html]ResultSet of Java has all the necessary methods to pick up the various types of data, including blob ..
Do you want string? ... use
rs.getString("nome_da_coluna")
if you want to boost your query you will have to use [url=http://java.sun.com/j2se/1.4.2/docs/api ... ement.html]PreparedStatement and start do an executeQuery () to get a resulse
-
- Information
-
Who is online
Users browsing this forum: No registered users and 15 guests