This discussion is archived
3 Replies Latest reply: Dec 20, 2012 1:35 AM by svanimpe RSS

odbc Connection network

975668 Newbie
Currently Being Moderated
Hi,

How can I create a network connection to access?

My connection work in local eg: "c:/..." but not in network "\\server\"


public void conectar(String caminhoarquivo){

try{

Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");

Properties ppt = new Properties();
ppt.put("charSet", "ISO-8859-1");


conexao = DriverManager.getConnection("jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+caminhoarquivo, ppt);

}catch(Exception e){

JOptionPane.showMessageDialog(null, "o Erro aconteceu na conecção");

// System.out.println("ERRO na Conexao com o Banco de Dados"+e.toString());

}

}
  • 1. Re: odbc Connection network
    975668 Newbie
    Currently Being Moderated
    Please, I need you help.
    I not resolved this question.
  • 2. Re: odbc Connection network
    James_D Guru
    Currently Being Moderated
    This isn't a JavaFX question; you should file it either in the Java Programming forum or (probably better) the Java Database Connectivity (JDBC) forum. A list of OTN Java forums is at https://forums.oracle.com/forums/category.jspa?categoryID=285

    You'll likely need more details than "doesn't work", too... (what errors are you getting and when, etc). But again, this is the wrong forum.
  • 3. Re: odbc Connection network
    svanimpe Newbie
    Currently Being Moderated
    You need to do the following:

    Register your database using the ODBC control panel in Windows. There you can couple a name (myDB for example) to your database (accdb/mdb file).
    In Java, all you need to do then is the following:
    Connection conn = DriverManager.getConnection("jdbc:odbc:myDB")
    to get a connection.

    Note the following: you need to use a compatible JVM. That is: if Access is 32-bit, you need a 32-bit JVM as well. Also, if Windows is 64-bit and Access is 32-bit, you need to use C\windows\sysWOW64\odbcad32.exe instead of the control panel.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points