Estou tendo alguns problemas para usar um banco access pelo meu programa escrito em java. Inicialmente eu tava fazendo testes usando o driver que jah vem no jdk, o banco e a aplicacao estao na minha maquina, ta tudo funcionando normal, mas eu vou precisar colocar essa aplicacao em outra maquina e o banco em outra maquina distinta. resumo: minha aplicacao vai ficar rodando num servidor Linux e o banco vai ficar rodando num servidor Windows. A aplicacao precisa acessar remotamente o banco access e para isso eu estou tentanto usar RMIJDBC, baixei o zip do rmi coloquei no classpath da minha aplicacao e tentei rodar um exemplo LOCAL usando esse conexao, soh para teste.
ae vao as classes que to usando.
[code]public final class BancoAccessRmi {
private static final String forNameAccessRmi = “org.objectweb.rmijdbc.Driver”;
private static final String dbNameAccessRmi = “PDTI”;
private static final String dbIpAccessRmi = “//127.0.0.1”;
private static final String dbPortAccessRmi = “1521”;
private static final String AccessUrlRmi = “jdbc:odbc:” + dbNameAccessRmi;
private static final String driverAccessRmi = “jdbc:rmi:” + dbIpAccessRmi + “:” + dbPortAccessRmi +
“/” + AccessUrlRmi;
public static String getForNameAccessRmi() {
return forNameAccessRmi;
}
public static String getDbNameAccessRmi() {
return dbNameAccessRmi;
}
public static String getDbIpAccessRmi() {
return dbIpAccessRmi;
}
public static String getDbPortAccessRmi() {
return dbPortAccessRmi;
}
public static String getAccessUrlRmi() {
return AccessUrlRmi;
}
public static String getDriverAccessRmi() {
return driverAccessRmi;
}
}[/code]
[code]public class ConnectionFactory {
public static Connection getConnectionAccessRmi() throws InstantiationException, IllegalAccessException, ClassNotFoundException, SQLException {
Class.forName(BancoAccessRmi.getForNameAccessRmi()).newInstance();
System.out.println(BancoAccessRmi.getForNameAccessRmi());
System.out.println(BancoAccessRmi.getDriverAccessRmi());
return DriverManager.getConnection(BancoAccessRmi.getDriverAccessRmi(), "", "");
}
}[/code]
[code]public class DAO {
protected Connection connection;
public Connection getConnection() {
return connection;
}
public void connectionClose () throws SQLException {
this.connection.close();
}
}[/code]
[code]public class AccessRmiDAO extends DAO{
public AccessRmiDAO() throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException {
this.connection = ConnectionFactory.getConnectionAccessRmi();
}
}[/code]
[code]public class Test {
public static void main(String[] args) throws SQLException, InstantiationException, IllegalAccessException, ClassNotFoundException, UnknownHostException {
Connection con = (Connection) new AccessRmiDAO();
}
}
[/code]
e o erro que ta dando eh esse:
java.rmi.ConnectException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
at sun.rmi.server.UnicastRef.newCall(UnicastRef.java:322)
at sun.rmi.registry.RegistryImpl_Stub.lookup(Unknown Source)
at org.objectweb.rmijdbc.Driver.lookupDriver(Driver.java:130)
at org.objectweb.rmijdbc.Driver.connect(Driver.java:199)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at br.gov.ce.seplag.cadastroSistemas.jdbc.ConnectionFactory.getConnectionAccessRmi(ConnectionFactory.java:21)
at br.gov.ce.seplag.cadastroSistemas.jdbc.DAO.AccessRmiDAO.<init>(AccessRmiDAO.java:12)
at br.gov.ce.seplag.cadastroSistemas.jdbc.DAO.Test.main(Test.java:10)
Caused by: java.net.ConnectException: Connection refused: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)
at java.net.Socket.connect(Socket.java:519)
at java.net.Socket.connect(Socket.java:469)
at java.net.Socket.<init>(Socket.java:366)
at java.net.Socket.<init>(Socket.java:179)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:595)
... 11 more
Exception in thread "main" java.sql.SQLException: Connection refused to host: 127.0.0.1; nested exception is:
java.net.ConnectException: Connection refused: connect
at org.objectweb.rmijdbc.Driver.connect(Driver.java:206)
at java.sql.DriverManager.getConnection(DriverManager.java:582)
at java.sql.DriverManager.getConnection(DriverManager.java:185)
at br.gov.ce.seplag.cadastroSistemas.jdbc.ConnectionFactory.getConnectionAccessRmi(ConnectionFactory.java:21)
at br.gov.ce.seplag.cadastroSistemas.jdbc.DAO.AccessRmiDAO.<init>(AccessRmiDAO.java:12)
at br.gov.ce.seplag.cadastroSistemas.jdbc.DAO.Test.main(Test.java:10)
eu jah criei o ODBC para o banco access que ta na minha maquina e jah to rodando o org.objectweb.rmijdbc.RJJdbcServer
alguem sabe me dizer qual o problema?
edit
soh para facilitar um pouco a leitura, ele ta fazendo isso no ConnectionFactory:
Class.forName("org.objectweb.rmijdbc.Driver").newInstance();
return DriverManager.getConnection("jdbc:rmi://127.0.0.1:1521/jdbc:odbc:PDTI", "", "");
PDTI eh o nome do ODBC que eu criei para o banco access na minha maquina