Error(9,8): method <init> not found in class bean.aces

2 respostas
S

Povo, socorro ?!
Seguinte, eu tow indo devagar mais esotu indo (risos) com a minha aplicação for web em java/jsp e tals…
Tenho uma duvida simples simples… tenho uma javabeans e desse javabenas estou instâncio uma classe chamada acessaBanco… esta dando um erro:

Error(9,8): method <init> not found in class bean.acessoBanco

Como soluciono isso ?!?!?!

2 Respostas

M

posta o código.

S

package bean;

import <a href="http://java.io">java.io</a>.<em>;

import java.util.Vector;

import javax.servlet.http.</em>;

import java.sql.<em>;

import java.util.</em>;
public class buscaCliente

{

String cli_codigo="",cli_nome="";

Vector colunasCliente;

acessoBanco ab = new acessoBanco();// NESSE PONTO JA ESTA SUBLINHADO PELO

// JDEVELOPER COM A MENSAGEM

// Error(13,24): method <init> not found in class bean.acessoBanco

public void setCodCli(String codigo)

{

ResultSet rst ;

colunasCliente.add(“CLI_CODIGO”);

colunasCliente.add(“CLI_NOME”);
try
{
  rst = ab.ExecSql( "CLI_CODIGO = 3152" , colunasCliente  );
  if(!rst.next())
  { 
    cli_codigo = rst.getLong("CLI_CODIGO");
    cli_nome = rst.getString("CLI_NOME");
  }
  else
  { 
    cli_codigo = "";
    cli_nome = "";
  }
}
catch(Exception e)
{
  e.printStackTrace();
}
}

public void setNomeCli(String nome)

{

cli_nome = nome;

}
public String getCodCli()

{

return cli_codigo;

}

public String getNomeCli()

{

return  cli_nome;

}

}

/********** CLASSE ACESSO BANCO ******************/

package bean;

import java.sql.*          ;

import java.util.*         ;

import javax.swing.JFrame;

import javax.swing.table.* ;

import javax.swing.JOptionPane;

public class acessoBanco
{

private Connection con;
private String tabela;
private String bancoDeDados;
private String url;
private String cmd;
public static final int INSERIR = 0;  //Definiçao de Constante	public static final int ALTERAR = 1; // Definição de Constante	public acessoBanco(String tab, String b) throws Exception
{

tabela = tab;

bancoDeDados = b;

Class.forName(“sun.jdbc.odbc.JdbcOdbcDriver”);

url = jdbc:odbc:SCAP;

}
public DefaultTableModel selecionarGeral(String select, Vector colunasParaLista)

throws Exception

{

con = DriverManager.getConnection(url);

Statement st;

ResultSet res;

Vector linhas = new Vector();

st = con.createStatement();

res = st.executeQuery(select);

if(!res.next()) { return new DefaultTableModel(null, colunasParaLista);}		

ResultSetMetaData rsmd = res.getMetaData();		

do { linhas.addElement(proximaLinha(res, rsmd)); } while (res.next());

st.close();

return new DefaultTableModel(linhas, colunasParaLista);

}
public DefaultTableModel selecionar(String whereInformado, Vector colunasParaLista)
throws Exception
{

con = DriverManager.getConnection(url);

Statement st;

ResultSet res;
Vector linhas = new Vector();

	st = con.createStatement();
	Iterator it = colunasParaLista.iterator();
	String colunas = it.next().toString();

	while (it.hasNext()) {colunas = colunas + ", " + it.next().toString();}

	String comando = "Select " +  colunas + " from " + tabela;

	if (whereInformado.trim().length()&gt;0)
{comando += " where " + whereInformado;}

/* Executa comando SQL no banco de dados */
	res = st.executeQuery(comando);

	if(!res.next()) {return new DefaultTableModel(null, colunasParaLista);}
	
	ResultSetMetaData rsmd = res.getMetaData();

	do {
		linhas.addElement( proximaLinha(res, rsmd));      
	} while (res.next());    
  st.close();
	return new DefaultTableModel( linhas , colunasParaLista );
}

public Vector proximaLinha(ResultSet rs, ResultSetMetaData rsmd)
		throws Exception {
	Vector linhaAtual = new Vector();

	for(int i=1; i&lt;=rsmd.getColumnCount(); i++)
	{ 
		switch(rsmd.getColumnType(i))
		{ 
			case Types.VARCHAR:
				linhaAtual.addElement(rs.getString(i));
				break;
			case Types.TIMESTAMP:          
				linhaAtual.addElement(rs.getTimestamp(i));
				break;
			case Types.TIME:
				linhaAtual.addElement(rs.getTime(i));
				break;
			case Types.DATE:
				linhaAtual.addElement(rs.getDate(i));
				break;
			case Types.REAL:
				linhaAtual.addElement(new Float(rs.getFloat(i)));
				break;
			case Types.INTEGER:
				linhaAtual.addElement(new Integer(rs.getInt(i)));
				break;
  }
	}
	return linhaAtual;
}

protected Object recuperar(String id) throws Exception
{

con = DriverManager.getConnection(url);

ResultSet res;

Statement st = con.createStatement();

String comando = "SELECT * FROM " + tabela + " WHERE ID = " + id;

res = st.executeQuery(comando);

res.first();		

st.close();

con.close();

return null;

}
public void remover(String id) throws Exception {
	con = DriverManager.getConnection(url);
	Statement st = con.createStatement();
	cmd = "DELETE FROM " + tabela + " " + id;
	st.executeUpdate(cmd);
	st.close();
	con.close();
}

public int executaSql(String cmd , boolean executaQuery  ) throws Exception
{

int       registrosAfetados=0;

ResultSet rst = null;
con = DriverManager.getConnection(url);
	Statement st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);    

if(executaQuery) {rst=st.executeQuery(cmd);}
else {registrosAfetados=st.executeUpdate(cmd);}

if(executaQuery)
{ registrosAfetados=0;
  // rst.first();
  while ( rst.next()) {registrosAfetados++;};
}
	st.close();
	con.close();
return registrosAfetados;
}

public String getBancoDeDados() { return bancoDeDados; }

/*  MODULO PARA RETORNO DE UM ARRAY COM AS LINHAS DO BANCO DE DADOS */
public Vector xs(String whereInformado, Vector colunasParaLista)

throws Exception

{

con = DriverManager.getConnection(url);

Statement st;

ResultSet res;

Vector linhas = new Vector();

st = con.createStatement();

Iterator it = colunasParaLista.iterator();

String colunas = it.next().toString();

while (it.hasNext()) {

colunas = colunas + ", " + it.next().toString();

}
String comando = "Select " +  colunas + " from " + tabela;

	if (whereInformado.trim().length() &gt; 0) {
		comando += " where " + whereInformado;
	}

/* Executa comando SQL no banco access */
	res = st.executeQuery(comando);

	if(!res.next()) {
		return  null ;
	}
	
	ResultSetMetaData rsmd = res.getMetaData();
	
	do {
		linhas.addElement( proximaLinha(res, rsmd));
	} while (res.next());

	st.close();
	return linhas ;
}
public Vector selecionaDados(String sql) throws Exception

{

con = DriverManager.getConnection(url);

Statement st;

ResultSet res;
Vector linhas = new Vector();

	st = con.createStatement();

/* Executa comando SQL no banco access */
	res = st.executeQuery(sql);

	if(!res.next()) { return null;}

	ResultSetMetaData rsmd = res.getMetaData();		
	do {
		linhas.addElement( proximaLinha(res, rsmd));
	} while (res.next());    
  st.close();    
	return linhas;
}

public ResultSet execSqlComando(String comando) throws Exception
{

String testaComando = comando.trim();

if( testaComando.length()&lt;=0) {return null;}
	con = DriverManager.getConnection(url);
	Statement st;
	ResultSet res;
st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_UPDATABLE);
	res = st.executeQuery(comando);
	if(!res.next()) {st.close();return null;}
	return res;
}
public int contaRegistros(String whereInformado, Vector colunasParaLista)

throws Exception

{

con = DriverManager.getConnection(url);

Statement st;

ResultSet res;

int retorno = 0 ;
Vector linhas = new Vector();

	st = con.createStatement();    
	Iterator it = colunasParaLista.iterator();
	String colunas = it.next().toString();

	while (it.hasNext()) {colunas = colunas + ", " + it.next().toString();}

	String comando = "Select " +  colunas + " from " + tabela;

	if (whereInformado.trim().length() &gt; 0)
{comando += " where " + whereInformado;}    

st = con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);        
res = st.executeQuery(comando);

if(res.next())
{
  res.first();
  do {retorno++;} while (res.next());
}
else {retorno=0;}

st.close();
	return retorno;
}
public ResultSet ExecSql(String whereInformado, Vector colunasParaLista)

throws Exception

{

con = DriverManager.getConnection(url);

Statement st;

ResultSet res;

ResultSet rstRetorno;

Vector linhas = new Vector();
st = con.createStatement();
	Iterator it = colunasParaLista.iterator();
	String colunas = it.next().toString();

	while (it.hasNext()) {colunas = colunas + " , " + it.next().toString();}

	String comando = "Select " +  colunas + " from " + tabela;

	if (whereInformado.trim().length() &gt; 0)
{comando += " where " + whereInformado;}

st=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
res = st.executeQuery(comando);    
rstRetorno = res;
// st.close();
	return rstRetorno;
}

}

Criado 10 de maio de 2005
Ultima resposta 10 de mai. de 2005
Respostas 2
Participantes 2