Outra coisa... verifique sua strUrl (nao deixe espacos em branco...)
Por que conectar no Oracle via ODBC ? Eh muito lento... a Oracle fornece driver nativos para acesso via Java
Verifique sua instalacao e procure pela pasta JDBC (dentro do diretorio onde o oracle foi instalado), la tem varios
exemplos de conexao ao Oracle
 
----- Original Message -----
Sent: Tuesday, November 20, 2001 4:03 PM
Subject: [java-list] Problemas com conexao

Amigos, criei uma classe para conectar o Oracle e esta dando problemas. Alguem poderia me sugerir como corrigir?
 
class Conectar {
 
 String strUrl;
 String strUsuario;
 String strSenha;
 Connection conexao;
 
 public Connection conexaoUniban(boolean blnConexaoParaProducao)  {
 
  if (blnConexaoParaProducao == true)  {
   this.strUrl = "jdbc: odbc: TESTE_MC";
   this.strUsuario = "teste";
   this.strSenha = "teste";
  }
  else if (blnConexaoParaProducao == false)  {
   this.strUrl = "jdbc: odbc: TESTE_DESENV";
   this.strUsuario = "testedesenv";
   this.strSenha = "testedesenv";
  }
  
  Class.forName("oracle.jdbc.driver.OracleDriver");  
  conexao = DriverManager.getConnection(this.strUrl, this.strUsuario, this.strSenha);
     
  return conexao;
 }
 
 public Conectar () {
 
 }
 
}
 
O erros foram os seguintes na compila��o:
 

OlaInternet.java:27: unreported exception java.lang.ClassNotFoundException; must be caught or declared to be thrown

Class.forName("oracle.jdbc.driver.OracleDriver");

^

OlaInternet.java:28: unreported exception java.sql.SQLException; must be caught or declared to be thrown

conexao = DriverManager.getConnection(this.strUrl, this.strUsuario, this.strSenha);

Agrade�o desde j� pela ajuda

 

Jefferson

Responder a