aspose file tools*
The moose likes JDBC and the fly likes about networking Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "about networking" Watch "about networking" New topic
Author

about networking

Jermaine Baker
Greenhorn

Joined: Aug 10, 2008
Posts: 3
hi all i am a newbie on java i am making a desktop application which does various database operations and it has a gui what i want to do is to make another copy of the program which does limited operations (no inserting or deleting for example) and the copy must read the database from the original application through internet or local network
what do i need for this kind of application,is networking api sufficient?
thanks for your interest
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42646
    
  65
Welcome to JavaRanch.

I'm not sure I understand the problem. You have two programs that connect to a database (presumably using JDBC in some form); the first one to read and write, the second read-only. Is that correct? If so, can't the second one connect to the DB in the same way as the first?

Having said that, I wouldn't open up a database for straight JDBC access over the internet. I'd probably use an intermediate server that proxies the requests, and also takes care of encryption.

As an aside, please use punctuation like you would normally in written communication; this isn't IRC or IM. It's much easier to understand (and you do want to make it easy to understand for other people, so that they're in a better position to help you).


Ping & DNS - my free Android networking tools app
Jermaine Baker
Greenhorn

Joined: Aug 10, 2008
Posts: 3
Sorry for the punctuation. The first program has Mysql in it and databases i made(used jdbc for java ) but I don't want to install Mysql on the second machine, rather i would like to make data transfer between first and second machine through internet or local network.
Thank you again.
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

Are the programs on the first and second machine the same program? Or basically do the same thing?

If so, you can use one program. The first one can connect to the database via localhost and the second one via the network. So you can use the same program. You can even pass in the same JDBC connection URL. But if you want to limit the one to read only, you can do that by using different database accounts. Se the one up to allow for inserts, updates, etc. And the other for selects only.

As for the Networking API, you will not need to use this directly. When you construct a DataSource to connect to the database, you can use a URL in uts construction. That will then connect to the remote database.
Mark Vedder
Ranch Hand

Joined: Dec 17, 2003
Posts: 624

The MySQL documentation section Connecting to MySQL Using the DriverManager Interface shows some example code of how to get a connection. The example is connection to the 'test' database' on the localhost. In the example code, 'localhost' can be replaced with any valid url like:

database.server.name.example.com

So you can use the same code to connect. You could even pass the DB connection URL in as a startup parameter or have it in a properties configuration file. This would allow for it to be changes easily.

Does that solve your issue?
Jermaine Baker
Greenhorn

Joined: Aug 10, 2008
Posts: 3
Ok, got it i havent tried it yet but url will probably solve my problem. Thank you everyone
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: about networking