• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

about networking

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).
 
Jermaine Baker
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, got it i havent tried it yet but url will probably solve my problem. Thank you everyone
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic