我需要使用数据库Firebird,为此我使用Jaybird 2.2.9。
当我使用MySQL驱动程序时,以这种方式将ResultSet转换为Object:
empresa.setBairro(rs.getString("empresa.bairro")); // (Table.Column)
empresa.setCep(rs.getString("empresa.cep")); // (Table.Column)
empresa.setCidade(rs.getString("empresa.cidade")); // (Table.Column)但是对于Jaybird,resultSet不返回rs.getString("Table.Column")
当我有内部加入SQL时,我需要这样做。
有人帮我吗?
这是我的完整代码
public ContaLivros converterContaLivros(ResultSet rs, Integer linha) throws Exception {
if (rs.first()) {
rs.absolute(linha);
ContaLivros obj = new ContaLivros();
obj.setId(rs.getLong("cad_conta.auto_id"));
obj.setNome(rs.getString("cad_conta.nome"));
if (contain("cad_banco.auto_id", rs)) {
obj.setBancoLivros(converterBancoLivros(rs, linha));
} else {
obj.setBancoLivros(new BancoLivros(rs.getLong("cad_conta.banco"), null, null, null));
}
obj.setAgencia(rs.getInt("cad_conta.agencia"));
obj.setAgenciaDigito(rs.getInt("cad_conta.agencia_digito"));
obj.setConta(rs.getInt("cad_conta.conta"));
obj.setContaDigito(rs.getInt("cad_conta.conta_digito"));
obj.setLimite(rs.getDouble("cad_conta.limite"));
obj.setAtivo(rs.getString("cad_conta.ativo"));
return obj;
} else {
return null;
}
}发布于 2015-12-30 08:44:17
Jaybird按照JDBC 4.2第15.2.3节中指定的标签检索列。在Firebird中,列标签要么是原始列名,要么是别名,表名不是其中的一部分。您可以在表名前加上消除歧义的MySQL的扩展是不标准的。
您的选项是在查询中指定别名并使用此别名检索,或者处理结果集元数据以为每一列查找正确的索引,而不是按索引检索。
但是,请注意,在某些查询(例如UNION)中,ResultSetMetaData.getTableName不能返回表名,因为Firebird并不“知道”它(因为您可以应用联合从不同的表中进行选择)。
发布于 2015-12-29 17:13:19
jdbc中的名称将不包含表。
你可以
getString (1);等)或
select a.name namefroma from tableone a )或
https://stackoverflow.com/questions/34515566
复制相似问题