aspose file tools*
The moose likes JDBC and the fly likes connecting to MS-Access Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Databases » JDBC
Reply locked New topic
Author

connecting to MS-Access

Ram Sateesh Talari
Greenhorn

Joined: Dec 03, 2003
Posts: 20
Hi Everyone...

This is the code which I am using to connect to a Remote MS Access DB using RmiJdbc. But couldn't succeed.

Someone Plz help...

=========================================
Code
=========================================
import java.sql.*;
import java.net.InetAddress;
import java.rmi.*;
import RmiJdbc.*;

public class rjdemo {

public static void main(String[] args) {
try {

Class.forName("org.objectweb.rmijdbc.Driver").newInstance();
String url = "jdbc dbc:rjdemo";
String rmiHost = new String("//172.16.8.50");// + InetAddress.getLocalHost().getHostName());

java.sql.Connection c = DriverManager.getConnection("jdbc:rmi:"
+ rmiHost + "/" + url, "Admin", "rjdemo");

java.sql.Statement st = c.createStatement();
java.sql.ResultSet rs = st.executeQuery("select * from contact");

java.sql.ResultSetMetaData md = rs.getMetaData();
while(rs.next()) {
System.out.print("\nTUPLE: | ");
for(int i=1; i<= md.getColumnCount(); i++) {
System.out.print(rs.getString(i) + " | ");
}
}
rs.close();
} catch(Exception e) {
e.printStackTrace();
}
}
};

=======================================
Exception
=======================================

java.rmi.ConnectException: Connection refused to host: 172.16.8.50; nested excep
tion is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.createConnection(Unknown Source)
at sun.rmi.transport.tcp.TCPChannel.newConnection(Unknown Source)
at sun.rmi.server.UnicastRef.newCall(Unknown Source)
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(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at rjdemo.main(rjdemo.java:15)
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(Unknown Source)
at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at java.net.Socket.<init>(Unknown Source)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(Unknown S
ource)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(Unknown S
ource)
... 10 more
java.sql.SQLException: Connection refused to host: 172.16.8.50; nested exception
is:
java.net.ConnectException: Connection timed out: connect
at org.objectweb.rmijdbc.Driver.connect(Driver.java:206)
at java.sql.DriverManager.getConnection(Unknown Source)
at java.sql.DriverManager.getConnection(Unknown Source)
at rjdemo.main(rjdemo.java:15)
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61064
    
  66

Ram, please continue discussion of the same issue in the same topic rather than starting a new one. Continue any discussion here.

thanks,
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: connecting to MS-Access