2

I made an inventory system in netbeans using the language java and i connect it to derby as my database it is already working as a whole system but I want to have a client-server functionality what I mean is I want my program to have a server which holds the database(different computer) and different users with different computers which they can save/view data at the same time to the database means they are connected in one network.

Working with multiple connections to a single database.

What code can I use or method or do I have to import something? I did some research and the only thing that I found is socket which can be used to create a chat between server and a client. But I only tried the IP 127.0.0.1 for the client since I am making running the server and the client in the same computer.

And also can I open the connection of the server in the client form and send data like SQLQuery so I can save it in the database of the server?

Where can I see examples for these? Please help thanks

Gin
  • 21
  • 1
  • 1
  • 3

2 Answers2

1

Yes, Derby supports a client-server configuration of your application.

Deploying your application in the client-server configuration is straightforward:

  1. Deploy the Derby Network Server, for example by running the startNetworkServer script that is included with the Derby distribution.
  2. Ensure that derbyclient.jar is in your application's CLASSPATH, and that you register "org.apache.derby.jdbc.ClientDriver" with the JDBC DriverManager.
  3. Change your JDBC Connection URL from jdbc:derby:<db details> to jdbc:derby://<host:port>/<db details>.

If this is your first time using Derby, I strongly recommend working your way through the Derby tutorial at https://db.apache.org/derby/docs/10.12/getstart/index.html

For more information about running the Derby Network Server to service database requests for your applications, read the Derby Admin Guide: https://db.apache.org/derby/docs/10.12/adminguide/index.html

Bryan Pendleton
  • 16,128
  • 3
  • 32
  • 56
  • Thanks for this information I am going to try the tutorials you recommend and yes this is my first time using derby as my database – Gin Jun 15 '16 at 00:14
0

Use the IP 0.0.0.0 or for all connections in the server. The the connection url should include the name of the server or the ip address of the server in the network. When you use ip 127.0.0.1 or localhost derby can only accept connections to the database in the same machine, in this case localhost. All of this can be done by your network application server