package versao3.persistencia.impl.jds;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Classe utilitaria para acesso ao JDataStore.
 */
public final class JDSDBUtil {
  private JDSDBUtil(){};

  static {
    try {
      Class.forName("com.borland.datastore.jdbc.DataStoreDriver");
    }
    catch (ClassNotFoundException ex) {
      System.err.print("Driver do banco nao encontrado.");
      System.exit( -1);
    }
  }

  public static Connection getConnection() {
    Connection conn = null;
    try {
      conn = DriverManager.getConnection(
          "jdbc:borland:dslocal:../db/jds/pedidosdb.jds",
          "DataStoreExplorer",
          ""
          );
    }
    catch (SQLException ex) {
      System.err.print("Erro ao obter conexao: " + ex.getMessage());
    }
    return conn;
  }

}
