4
I have the following scheme:
JdbcRowSet myrs = new JdbcRowSetImpl();
myrs.setUrl("jdbc:postgresql://localhost:9999/teste");
myrs.setUsername("postgres");
myrs.setPassword("");
myrs.setCommand("select count (*) from pessoas where cpf = '12345'");
myrs.execute();
ResultSetMetaData md = myrs.getMetaData();
String columncount = //Exemplo: getColumnName(1);
if ( columncount == 12345){
return ("existe");
} if ( columncount != 12345){
return ("inexiste");
}
Does anyone know the method that would apply instead of the /Example to capture the contents of the "Cpf" column for confirmation of the existence of Cpf "12345"?
Hello, @bupereira. Welcome to [pt.so]! Really the
getString
is a way out. Probably the use ofResultSetMetaData
is just a misunderstanding. However, as the query returns the count of records, I think it would be best to use thegetInt
to assign to an integer variable and toif
check if more than one record:if (count > 0)
.– utluiz
Thanks for the answers, but it’s not working >.<
– OsírisAguiar
You get some mistake?
– bupereira
I posted the error as an answer to better read, follows below:
– OsírisAguiar
I did it! I did the following: Jdbcrowset myrs = new Jdbcrowsetimpl(); myrs.setUrl("jdbc:postgresql://localhost:9999/test"); myrs.setUsername("postgres"); myrs.setPassword("); myrs.setCommand("select * from people"); myrs.execute(); ; }
– OsírisAguiar
Ball show! Just score there as solved and let’s go next!
– bupereira