File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes JDBC over LAN Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "JDBC over LAN" Watch "JDBC over LAN" New topic
Author

JDBC over LAN

Philipe Breiding
Greenhorn

Joined: Aug 15, 2009
Posts: 3
Hello everyone,

I am trying to access a databaste that is stored on a remote computer within my LAN network. So far I have assembled the following code:



If I try entering the IP address of the remote computer in conjunction with the database file path after "DBQ=", I get an error.

Can anyone help? Thanks in advance!
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Not sure exactly with MS Access. However, in the case of MySQL, you just need to include the IP address of the remote machine and make sure the Database server is up and running.

For example: jdbc:mysql://IP Address/database Name

Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

If memory serves, Access is a file based database. If you want network sharing, the file will need to be placed on a shared folder.

Of course, this was a while ago. Haven't played with Access in a while.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2503
    
    8

Henry Wong wrote:If memory serves, Access is a file based database. If you want network sharing, the file will need to be placed on a shared folder.

Of course, this was a while ago. Haven't played with Access in a while.

Henry
This is correct. The OP will have to put the database in a shared location.
Then he will have to create an ODBC datasource that points to that location.

Since Access is a file database, the protocol to query the database (file access) is a heavy protocol that requires significant bandwidth. Better use a client/server database in that case (or to be honest: in any case)


OCUP UML fundamental and ITIL foundation
youtube channel
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18643
    
    8

No, IP address isn't good enough. This is MS Access, not some web-friendly software. You have to provide a file name after that "DBQ" thing. Mapping a drive would help, but possibly a UNC path name would work just as well.
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
Unless you are just trying simple stuff out, you may want to look into a "real" database that is free, such as mySQL.

Philipe Breiding wrote:Hello everyone,

I am trying to access a databaste that is stored on a remote computer within my LAN network. So far I have assembled the following code:



If I try entering the IP address of the remote computer in conjunction with the database file path after "DBQ=", I get an error.

Can anyone help? Thanks in advance!
Philipe Breiding
Greenhorn

Joined: Aug 15, 2009
Posts: 3
Heya, thanks for the replies.

I did a bit of research and often come across "DSN connections" in order to access the database via LAN. Does anyone know how to do this? I also attempted to write client/server socket-based classes which establish a connection on a specific port. I can connect the two computers, I'm just not too sure where to put the database commands. This is a school project, so no major code is required.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Philipe Breiding wrote:
I did a bit of research and often come across "DSN connections" in order to access the database via LAN. Does anyone know how to do this? I also attempted to write client/server socket-based classes which establish a connection on a specific port. I can connect the two computers, I'm just not too sure where to put the database commands. This is a school project, so no major code is required.


A "DSN connection" doesn't mean that it is a network connection -- it is merely a connection to the DB. If you want to have DB network support, you'll need a DB that supports it. With Access, it is a file based DB, so you'll need to use a shared folder for accessing a db on another machine.

As for DB that supports network access, there are tons of them, and they are all free -- even the commercial ones. MySQL was already mentioned. Postgres is also highly recommended. I have also used Ingres and hypersonic in the past -- which are okay. But best of all, for development projects, all the major manufacturers have free "express" versions (limited usage) -- Oracle, DB2 (IBM), SqlServer (Microsoft). Heck, Microsoft even has a developer's version for $50 -- which is a fully feature enterprise edition that is restricted to developer usage only.

Henry
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Oops, didn't answer your question...

I also attempted to write client/server socket-based classes which establish a connection on a specific port. I can connect the two computers, I'm just not too sure where to put the database commands.


Doing what you are doing -- using JDBC is a good way to go. You just need to install a DB that does what you want.

With JDBC, once you have a connection to the database, you can create statements and execute queries.

Henry
Philipe Breiding
Greenhorn

Joined: Aug 15, 2009
Posts: 3
Thanks so much, really cleared things up. Unfortunately, we HAVE to use MS access, so my only option would be to place it into a shared folder and enter the IP address of the remote computer where it says DBQ= right? I would really prefer to use the previously mentioned client/server classes as that would result in more marks for originality do you think it would be possible to do this?

Regards
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

Philipe Breiding wrote:Unfortunately, we HAVE to use MS access, so my only option would be to place it into a shared folder and enter the IP address of the remote computer where it says DBQ= right?


No. Once the file is on the shared folder, you just need to specify the file -- just like you would have to do it, if it wasn't on the shared folder... And BTW, don't guess, google for instructions on configuring JDBC for access.

Philipe Breiding wrote:I would really prefer to use the previously mentioned client/server classes as that would result in more marks for originality do you think it would be possible to do this?


You do know that technically this isn't client / server, as there isn't a DB server, right? All you are doing is configuring JDBC to bridge over to ODBC to load the windows access libraries that parses a MDB file.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JDBC over LAN