Your problems are threefold:
1. Trying to use win32ole/OLEDB on a non-Windows machine
Chances are extremely good that you simply cannot use win32ole
in a Ruby app running on a non-Windows machine. And even if you could, your code would require an OLEDB provider for Access on your Linux box, and I doubt that such a thing exists.
2. Connecting to the database file
here i want to use the ip address
and port number
You can't do that. In order to connect to an Access database on a remote machine you need to connect to a Windows shared folder, not a TCP port. So, on the Windows server you would have a shared folder and on the Linux client you would mount that folder.
3. Database access
If win32ole
is not available then you need to use some other database access technology. ODBC is a common choice, but unfortunately ODBC support for Access databases on Linux (via "mdb tools" and "unixODBC") is quite unreliable, at least in my experience.
Solution
In your case, I would be inclined to try using JRuby and the UCanAccess JDBC driver. I just successfully tested it on my Ubuntu 14.04 LTS box with the JRuby code ...
connUrl = "jdbc:ucanaccess:///mnt/weezerpublic/uca301demo.accdb"
conn = java.sql.DriverManager.get_connection(connUrl)
stmt = conn.create_statement
rs = stmt.execute_query("SELECT TextField FROM myTableInAccess WHERE ID=1")
while (rs.next) do
puts rs.getString("TextField")
end
conn.close
... invoked via the shell script ...
#!/bin/bash
export CLASSPATH=.:/home/gord/Downloads/JDBC/UCanAccess/loader/ucanload.jar
jruby jrubyTest.rb
... with the following caveats:
- Windows file sharing won't work over a plain Internet connection. You would require a VPN connection to access such a shared folder over the Internet.
- The UCanAccess JDBC driver has significant limitations regarding concurrent write access to a database from multiple processes. If your Ruby app must support multiple concurrent users who need to update – not just read – the database then you'd be better off using some other database (e.g., Microsoft SQL Server, MySQL, ...) as the back-end.