Problemas no JDBC com acess

:frowning:

     Ao tentar executar a classe abaixo recebo o seguinte erro:
     No suitable driver erro no conecta

java.lang.NullPointerException
at AcessConnector.getField(AcessConnector.java:53)
at AcessConnector.main(AcessConnector.java:69)
Exception in thread “main”

import java.sql.*;

public class AcessConnector {

final static private String dvr = “sun.jdbc.odbc.JdbcOdbcDriver”;
final static private String url = “jdbc.odbc.rsp”;
private Connection con;

public boolean conecta(){
boolean retorno = true;
try {
Class.forName(dvr);
con = DriverManager.getConnection(url,"","");
}
catch (ClassNotFoundException er1){
System.out.println(er1.getMessage());
retorno = false;
}
catch (SQLException er2){
System.out.println(er2.getMessage() + " erro no conecta");
retorno = false;
}
return retorno;
}

public void desconecta(){
try{
con.close();
}
catch(SQLException er2){
System.out.println( er2.getMessage() + “erro no desconecta”);
}
}
public String getField ( int num ){
try {
Statement stmt = con.createStatement();
String query = “SELECT * FROM AGENTES”;
ResultSet rs = stmt.executeQuery(query);
String columvalue = rs.getString(num);
rs.close();
stmt.close();
return columvalue;
}
catch (SQLException er){
System.out.println(er.getMessage() + “error no getField”);
return “error no getField”;
}
}
public static void main (String [] args){
AcessConnector Acess = new AcessConnector();
Acess.conecta();
System.out.println(Acess.getField(1));
Acess.desconecta();
}
}

Alguem pode me disser o que estĂĄ errado? :?: :?: :?: :?: :?:

[quote=“Luiz-SP”]:frowning:

     Ao tentar executar a classe abaixo recebo o seguinte erro:
     No suitable driver erro no conecta

java.lang.NullPointerException
at AcessConnector.getField(AcessConnector.java:53)
at AcessConnector.main(AcessConnector.java:69)
Exception in thread “main”

import java.sql.*;

public class AcessConnector {

final static private String dvr = “sun.jdbc.odbc.JdbcOdbcDriver”;
final static private String url = “jdbc.odbc.rsp”;
private Connection con;

public boolean conecta(){
boolean retorno = true;
try {
Class.forName(dvr);
con = DriverManager.getConnection(url,"","");
}
catch (ClassNotFoundException er1){
System.out.println(er1.getMessage());
retorno = false;
}
catch (SQLException er2){
System.out.println(er2.getMessage() + " erro no conecta");
retorno = false;
}
return retorno;
}

public void desconecta(){
try{
con.close();
}
catch(SQLException er2){
System.out.println( er2.getMessage() + “erro no desconecta”);
}
}
public String getField ( int num ){
try {
Statement stmt = con.createStatement();
String query = “SELECT * FROM AGENTES”;
ResultSet rs = stmt.executeQuery(query);
String columvalue = rs.getString(num);
rs.close();
stmt.close();
return columvalue;
}
catch (SQLException er){
System.out.println(er.getMessage() + “error no getField”);
return “error no getField”;
}
}
public static void main (String [] args){
AcessConnector Acess = new AcessConnector();
Acess.conecta();
System.out.println(Acess.getField(1));
Acess.desconecta();
}
}

Alguem pode me disser o que estĂĄ errado? :?: :?: :?: :?: :?:[/quote]

Olha o erro aqui:

final static private String url = "jdbc.odbc.rsp"; 

o correto Ă©:

final static private String url = "jdbc:odbc:rsp"; 

:oops: :oops: :oops:

     Putz que vacilo. Valeu :lol: 

Luiz-sp