Ol� lista,


Estou usando java jdk 2 standard edition em windows 95, mas nao consigo
me conectar
via ODBC (eca) num banco de dados Ms Access 97 (eca2) .
Segue em anexo o codigo java, a linha
Class.forName("sun.jdbc.odbc.JdbcOdbc");
funciona legal, mas se tirar o "sun." da erro.
Outra coisa, a linha
Connection Ex1Con = DriverManager.getConnection( "jdbc:odbc:estuda");
gera uma SqlException.
Sou novo em java e programo desde 1986.
Algum especialista poderia me ajudar?

Obrigado

Krikor.




// Chapter 15 : Program #2 alterado por Krikor 09;03.2000
import java.sql.*;
import java.io.*;
import javax.swing.*;
import java.util.*;

public class conecta {


public static void UpdateStudentName(String StFName, String StLName,String StNo)  {

        String strDriver = "jdbc.odbc.JdbcOdbcDriver";

        int RetValue;
try {
        // Initialize and load the JDBC-ODBC driver.
        Class.forName("sun.jdbc.odbc.JdbcOdbc");
        // Make the connection object.
        }

        catch (ClassNotFoundException e) {System.out.println("Err1"); }

try {
        Connection Ex1Con = DriverManager.getConnection( "jdbc:odbc:estuda");
        System.out.println("'passo 1");

        // Create a simple Statement object.
        Statement Ex1Stmt = Ex1Con.createStatement();
        System.out.println("'passo 2");

        //Make a SQL string, pass it to the DBMS, and execute the SQL statement
        ResultSet Ex1rs = Ex1Stmt.executeQuery("SELECT StudentNumber, FirstName, 
LastName FROM Students");
        System.out.println("'passo 3");

        //Process each row until there are no more rows.
        // Displays the results on the console.
        System.out.println("Student Number        First Name      Last Name");
        while (Ex1rs.next()) {
                // Get the column values into Java variables
                StNo = Ex1rs.getString(1);
                StFName = Ex1rs.getString(2);
                StLName = Ex1rs.getString(3);
                System.out.println(StNo+" "+StFName+" "+StLName);
            }
   
     }
     catch (SQLException x) {System.out.println("Err2"); }
}

public static void main(String SS[]) {
   UpdateStudentName("joao", "Silva", "1");
   System.out.println("teste");
   }

}

Responder a