Jdbc e firebird

5 respostas
C

É A PRIMEIRA FEZ QUE ESTOU CRIANDO UM TOPIC NO FORUM…

GOSTARIA DE SABER COMO EU FAÇO PARA RESOLVER O PROBLEMA DE ACESSO REGRESSIVO COM O FIREBIRD, POIS NÃO ESTOU CONSEGUINDO “VOLTAR REGISTROS”.

tenho um objeto ResultSet rs
e acesso os métodos rs.next(), rs.last(), rs.first() numa boa, mas não consigo acessar o rs.previous().
----Acho que não está implementado ou algo desse tipo. Segue o erro abaixo:

org.firebirdsql.jdbc.FBDriverNotCapableException: Result set is TYPE_FORWARD_ONLY

at org.firebirdsql.jdbc.FBCachedFetcher.previous(FBCachedFetcher.java:157)

at org.firebirdsql.jdbc.FBResultSet.previous(FBResultSet.java:996)

at janelas.CadastroDeGrupo.jButtonRegistroAnteriorActionPerformed(CadastroDeGrupo.java:192)

at janelas.CadastroDeGrupo.access$100(CadastroDeGrupo.java:13)

at janelas.CadastroDeGrupo$2.actionPerformed(CadastroDeGrupo.java:85)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1764)

at javax.swing.AbstractButton$ForwardActionEvents.actionRESULTADO antes: false

Passou do setEnabled: !rs.isFisrt()

Performed(AbstractButton.java:1817)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:419)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:257)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)

at java.awt.Component.processMouseEvent(Component.java:5134)

at java.awt.Component.processEvent(Component.java:4931)

at java.awt.Container.processEvent(Container.java:1566)

at java.awt.Component.dispatchEventImpl(Component.java:3639)

at java.awt.Container.dispatchEventImpl(Container.java:1623)

at java.awt.Component.dispatchEvent(Component.java:3480)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3450)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3165)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3095)

at java.awt.Container.dispatchEventImpl(Container.java:1609)

at java.awt.Window.dispatchEventImpl(Window.java:1590)

at java.awt.Component.dispatchEvent(Component.java:3480)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:450)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:197)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)

----SEGUE TAMBÉM UM POUCO DA DOCUMENTAÇÃO DO DRIVER:

previous
public boolean previous()
throws java.sql.SQLExceptionMoves the cursor to the previous row in this ResultSet object.
Note: Calling the method previous() is not the same as calling the method relative(-1) because it makes sense to callprevious() when there is no current row.

Specified by:
previous in interface java.sql.ResultSet
Returns:
true if the cursor is on a valid row; false if it is off the result set
Throws:
java.sql.SQLException - if a database access error occurs or the result set type is TYPE_FORWARD_ONLY
Since:
1.2
See Also:
What Is in the JDBC 2.0 API

—UM PEDAÇO DO CÓDIGO FONTE DA MINHA APLICAÇÃO

stmt = conexao.createStatement(
java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE,
java.sql.ResultSet.CONCUR_READ_ONLY )
;

GOSTARIA DE SABER COMO FAÇO PARA RESOLVER ISSO.

OBRIGADO

5 Respostas

E

ow carlosbrp.

blz véio.

kra eu uso muito firebird.

e kra faco selects sem problema.

so uma pergunta (desculpa minha ignorancia) mais por que você cria o statement dessa forma ???

stmt = conexao.createStatement( 
java.sql.ResultSet.TYPE_SCROLL_INSENSITIVE, 
java.sql.ResultSet.CONCUR_READ_ONLY );

eu faco assim oh

stmt = conexao.createStatement();
java.sql.ResultSet rs = stmt.executeQuery("select * from cliente");
while (rs.next())
{
  /*
  Ai você pega os valores com:
  rs.getString("NOMECAMPO");
  rs.getInt("NOMECAMPO");
  ...
 */
}

naum se eh isso q vc quer mais, tentei…

flow kra té

C

Olá edgardksb,

É o seguinte. Vejo que os Drives para o FireBird só tem acesso progressivo(rs.next()) quanto a implementação da interface ResultSet. Então em uma tentativa eu resolvi usar como parâmetros para criação do Statement parâmetros que podemos determinar como poderia ser acessado os dados. Mais infelismente não consegui o acesso regressivo no objeto ResultSet (rs.previous() ).

edgardksb, gostaria de ver um exemplo de aplicação sua, pois vejo que você não notou esse “probleminha” quanto a interface ResultSet.
Ahhh… e gostaria se você tem um exemplo da sitaxe CHECK( expressão ) na CREATE TABLE para me mostrar.

Agradeço a atenção sobre meu post no forum.
AHH… e responda viu? :lol:

E

ow veio

eu aqui de novo.

consegui fazer o create table, alter table, insert into, update set assim oh

stmt = conexao.createStatement();
String SQL;
SQL = "create table teste " +
     "(codigo integer not null, " +
     " nome varchar(30), " +
     " primary key(codigo))";
int nLinhas = stmt.executeUpdate(SQL);

/* Sendo que nLinhas será o numero de linhas afetadas 
 (nesse caso nenhuma) */

da uma olhada ai véio, vê c funciona isso ai

flow…

D

carlosbrp

Eu consegui deste modo, tente ai, qualque coisa tente pegar o drive do FB mais atualizado.

[]'s

Anderson

Connection conn = DriverManager.getConnection(url,usr,pwd); conn.setAutoCommit(false); Statement stm = conn.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE);

C

Derso,

eu tive o mesmo problema, mais o que você respondeu foi a solução. :slight_smile:

Criado 11 de abril de 2004
Ultima resposta 8 de mai. de 2004
Respostas 5
Participantes 4