Ola!
Estou usando o Eclipse e estou tentando acessar o MySQL com o codigo abaixo que tirei de um livro mas nao esta dando certo.
import java.sql.*;
/*
* Created on 25/11/2003
*
* To change this generated comment go to
* Window>Preferences>Java>Code Generation>Code Template
*/
/**
* @author Giovana
*/
public class CorreVend {
final private String url = "jdbc:mysql://localhost:3306/vendas";
final private String drv = "org.gjt.mm.mysql.Driver";
private CorreVend(){
try {
Class.forName(drv);
Connection con= DriverManager.getConnection(url,"root","");
Statement stm = con.createStatement();
ResultSet rs = stm.executeQuery("Select * from vendedor");
if(rs.isAfterLast() ==false)
rs.afterLast();
while (rs.previous())
System.out.println(rs.getString(1)+ "" + rs.getString(2));
}catch(ClassNotFoundException e){
System.err.print(e.getMessage());
}catch(SQLException e1){
System.err.print(e1.getMessage());
}catch(Exception e3){
System.err.print(e3.getMessage());
}
}
public static void main(String [] args){
CorreVend aplic = new CorreVend();
}
}
Quando executo a classe sempre cai aqui: catch(ClassNotFoundException e).
Em C:j2sdk1.4.1_02liborggjtmmmysql coloquei o drive do MySQL (descompactei um zip que veio no CD).
Sera que a zebra nao ta no Eclipse? Ou seja, serah que nao tenho q referenciar este drive na IDE?
Giovana