Running a Java program that connects to a localhost database on a different computer


I've connected my really basic Java application to the Wamp server on my computer using the following code

try { Class.forName("com.mysql.jdbc.Driver"); Connection connection = DriverManager.getConnection( "jdbc:mysql://localhost:3306/project", "root", "password");

Obviously, this program runs on my computer, but no one else's, and I need to submit this as a project.

Is there anyway I can modify this part so that my partner and teacher can run the code from their computers, without having to download any special software, and access the database on my localhost? Possibly like replacing //localhost:3306 with //my IP address:8080?

All suggestions I've gotten involve networking, which I don't know anything about so I don't want to try and then mess up my computer unless I'm really sure

Things I've already looked in to, but aren't sure about:

<ul><li>C:/wamp/alias/phpmyadmin.conf and entering the line ALLOW (other person's IP) </li> <li>team viewer (requires the other computer to use software other than my program)</li> <li>opening my router port to take incoming requests</li> </ul>

Anything'll help guys, even just confirming it can't be done without some networking. If it's something an inexperienced person can do, I'll take it.


Apart from what you have tried, you also need granting privileges to access your database.

Try granting privileges to users from other IP addresses.

Read documentation <a href="http://dev.mysql.com/doc/refman/5.1/en/grant.html" rel="nofollow">GRANT Syntax</a>.


GRANT ALL ON test.* TO '%'@'localhost' ... GRANT ALL ON test.* TO '%'@'%' ... GRANT ALL ON test.* TO 'ravinder'@'' ... etc...

There are other forms of granting access to specific database object to specific or all users connecting from a specific computer or all.<br /> I suggest you chose the one which is appropriate for your need.

But, keep in mind that '%'@'%' will allow <em>all</em> users from <em>all</em> systems.

After granting the privileges, change your dbURL value for connection string with your IP address.

Connection connection = DriverManager.getConnection( "jdbc:mysql://your_system_ip_or_name_here:3306/project", "root", "password");

Deploy the regenerated app on desired systems and it should be working.


  • How do I save GORM objects with multiple many-to-one relationships?
  • Which event is called when a user click on the disabled item in context menu?
  • Rspec doesn't reload changed password attribute - why?
  • Write-progress trouble with foreach loop
  • How can I serialize entities from an ASP.NET MVC site to XML?
  • Thrift Client can't connect
  • How to read a certificate from a USB token in C#
  • Oracle SQL: Receiving 'no matching unique or primary key' error and don't know why
  • disablinging autorecover option for powepoint
  • Creating a C++ function that calls other Lua function
  • Why isn't my “Fizz Buzz” test in R working?
  • Synchronize windows folders
  • Validate jQuery plugin, field not required
  • How to autopopulate a field in SugarCRM form
  • configure: error: no acceptable C compiler found in $PATH
  • saving file generated by TCPDF
  • Button click event not firing in jQuery
  • Eclipse CDT error: Unable to compile
  • OOP Javascript - Is “get property” method necessary?
  • chrome.tabs.executeScript only fires when the Developer Console is open
  • Content-Length header not returned from Pylons response
  • JSON response opens as a file, but I can't access it with JavaScript
  • Python urlparse: small issue
  • Projection media query: browser support and workarounds?
  • Master page gives error
  • Nant, Vault & Windows Integrated Authentication
  • What is Eclipse's Declaration View used for?
  • req.body is undefined - nodejs
  • Perl system calls when running as another user using sudo
  • Can I make an Android app that runs a web view in Chrome 39?
  • Redux, normalised entities and lodash merge
  • Jquery - Jquery Wysiwyg return html as a string
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • Acquiring multiple attributes from .xml file in c#
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Append folder name and increment by 1 using batch script
  • java string with new operator and a literal