how to access remote database in java

Subscribe to RSS

How to access the remote database using java. Ask Question Asked 8 years, 2 months ago. Active 8 years, 2 months ago. Viewed 2k times 1. Iam trying to access database from system to other system, below is code. import datingyougirl.comtion; import datingyougirl.comManager; import datingyougirl.comSet; import datingyougirl.comeption; import datingyougirl.com Just supply the IP / hostname of the remote machine in your database connection string, instead of localhost. For example: jdbc:mysql:///yourdatabase Make sure there is no firewall blocking the access to port Also, make sure the user you are connecting with is allowed to connect from this particular hostname.

Join Stack Overflow to learn, share knowledge, and build your career. Connect and share knowledge within a single location that is structured and easy to search.

I am using a remote mySQL server as my database. How do I connect to this remote database for creating tables and accessing them? For example:. Also, make sure the user you are connecting with is allowed to connect from this particular hostname. First close all connection then restart all tools MySQL,apache etc. Instead of skip-networking the default is now to listen only on localhost which is more compatible and is not less secure.

How are we doing? Please help us improve Stack Overflow. Take our short survey. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? Learn more.

Ask Question. Asked 11 years, 1 month ago. Active 2 years, 3 months ago. Viewed k times. Improve this question. Gord Thompson Angeline Angeline 2, 22 22 gold badges 67 67 silver badges bronze badges.

Add a comment. Active Oldest Votes. Improve this answer. Bozho Bozho k gold badges silver badges bronze badges. Angeline: Pls accept this answer, since this is the correct answer for the question asked — Surya Chandra Mar 28 '12 at And 3 Change all references within an. Joachim Sauer k 54 54 gold badges silver badges bronze badges. Instead of local host i replaced my remote machine address. I have obtained remote access to the mysql server. In case some behind me makes this same mistake.

You will never, ever, for any purpose or reason, be able to connect to a remote machine using either localhost or Barbati Feb 15 '17 at Puran Singh Puran Singh 76 3 3 bronze badges.

And port forwarding when you are behind NAT! I understood better with the 2nd Answer there: what is magneto optical disk. Buminda Buminda 7 7 silver badges 15 15 bronze badges. Jack Mason Jack Mason 2 2 silver badges 2 2 bronze badges. The Overflow Blog. Podcast How to build and maintain online communities, from gaming to…. Level Up: Creative Coding with p5.

Featured on Meta. Stack Overflow for Teams is now free for up to 50 users, forever. Outdated Answers: results from use-case survey. Downvotes Survey results. Linked 2. Related Hot Network Questions. Question feed. Stack Overflow works best with JavaScript enabled. Accept all cookies Customize settings.

Navigation menu

I'm trying to access a remote database (MySQL) that is installed on my home computer. The code is: public void initDB(String ipaddress, String databasename, String login, String pass) { try { datingyougirl.come("datingyougirl.com"); db = (Connection) datingyougirl.comnection("jdbc:mysql://" + ipaddress + "/" + databasename, login, pass); statement = (Statement) datingyougirl.comStatement(); datingyougirl.comn("Database is connected."); } catch (Exception e) .

I'm trying to access a remote database MySQL that is installed on my home computer. The code is:. This code works perfectly with the local database when the code is executed from my home computer. Now I'm trying to run the code from another computer, and I cannot connect to the database. Where could be the problem? Some details about the database: I'm using Wamp server. To allow a remote access, I've opened the file phpmyadmin.

That is all I've done. Maybe, I missed something, don't know Firewal, firewall, firewall. You might have opened the "phpadmin" port whatever port that is , but you seemingly have not opened the standard DB port, and your firewall simply drops packets. Thank you. I suppose that I've configured grants properly. It seems that the problem is really connected with opening the standard DB port. Hmm, I'm not very good in this topic Is it exactly what you mean?

Program will exit. Also, you do know that it is extremely unsafe to expose these ports, right? Yes, I know that exposing ports is unsafe. I guess it is impossible, is it? Set up a web service? And access the db through "proxy". In which case, it doesn't do much good anymore. I've solved the problem. Then I've created a database, a table and a user. Finally, I've granted all privileges to that user:. We're a friendly, industry-focused community of 1.

Hi guys! Below you may see an error message: Could not initialize the database. CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. ConnectException: Connection timed out: connect at java. Answered by masijade 1, in a post from 10 Years Ago.

Also, don't forget to properly configure your grants. Jump to Post. Different problem. Start your own thread and learn about classpaths. Facebook Like. Twitter Tweet.

Be a part of the DaniWeb community. Sign Up — It's Free! This topic is old! No one has contributed to this discussion in over 10 years. Are you sure you have something valuable to add to revive the existing conversation? Consider starting a new topic instead. Otherwise, please be thoughtful, detailed and courteous, and adhere to our posting rules. Edit Preview. H1 H2. Post Reply. Insert Code Block. Share Post. Permanent Link.