createStatement

4 respostas
fsf

Oi pessoal,

Quando chamo um metodo pela segunda vez para, atualizar um jcombobox, o createStatement esta gerando o seguinte erro:
java.sql.SQLException: General error at sun.jdbc.odbc.JdbcOdbc.throwGenericSQLException(Unknown Source) at sun.jdbc.odbc.JdbcOdbc.SQLAllocStmt(Unknown Source) at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(Unknown Source) at sun.jdbc.odbc.JdbcOdbcConnection.createStatement(Unknown Source) at interfaces.GuiGestora.ListarCodGestora(GuiGestora.java:293) at interfaces.GuiGestora$2.actionPerformed(GuiGestora.java:165) at javax.swing.AbstractButton.fireActionPerformed(Unknown Source) at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source) at javax.swing.DefaultButtonModel.setPressed(Unknown Source) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source) at java.awt.Component.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)
Alguém tem alguma idéia do que esta acontecento!!!Veja o metodo:
public void ListarCodGestora() {
			conexao();
	
		
	
	String h = "";
	
	
	
		
		//bloco try responsavel por recuperar os dados da funcao
		try {

			
		    dados.removeAllElements();
		    teste.addElement(h);
				

			

         String sql = "Select cod_ug from gestora";		
		 Stmt = con.createStatement();//linha 293
			RS =
				Stmt.executeQuery(sql);

			
		
			   
			RS.next();	
			do {

		
		teste.addElement(RS.getString("cod_ug"));
						
			} while (RS.next());

		dados = new DefaultComboBoxModel(teste); 
				
		} catch (SQLException ex) {

			 ex.printStackTrace();    
		//	JOptionPane.showMessageDialog(
		//		null,
		//		"Não existe Unidade Gestora Cadastrada!",
		//		"Mensagem",
		//		JOptionPane.ERROR_MESSAGE);
		}

		fechar();

			
		gestora= new javax.swing.JComboBox(dados);
		getContentPane().add(gestora);
		gestora.setBounds(110, 26, 240, 20);
		  
						
		//validate();
		gestora.repaint();
			
		}

4 Respostas

Rafael_Steil

ODBC? que banco de dados vc esta usando?

Rafael

fsf

Tô usando o access!

cu_ringa

coloca ai esse teu metodo conexao() e fechar() pra gente da uma sacada

fsf
Veja a baixo os métodos conexao e fechar!
public void conexao() {

		try {
		String  url="jdbc:odbc:sgic";
				
						 Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
						con=DriverManager.getConnection(url);
              
                

	} catch (Exception e) {
			
          JOptionPane.showMessageDialog(
			null,
			"Erro de acesso ao banco!",
			"Mensagem",
						JOptionPane.ERROR_MESSAGE);
				}
			}

   public void fechar() {
 	try {
	con.close();
	} catch (Exception e) {
					JOptionPane.showMessageDialog(
			null,
		"Erro ao tentar fechar o banco!",
						"Mensagem",
						JOptionPane.ERROR_MESSAGE);
				}
			}
Criado 4 de abril de 2005
Ultima resposta 5 de abr. de 2005
Respostas 4
Participantes 3