Blog coding and discussion of coding about JavaScript, PHP, CGI, general web building etc.

Saturday, August 6, 2016

How to successfully access the database on another computer using java and jdbc and sql?

How to successfully access the database on another computer using java and jdbc and sql?


i have this database on another pc and i want to access it by using a connection string like this.

Class.forName("com.mysql.jdbc.Driver");           con = DriverManager.getConnection("jdbc:mysql://192.168.0.1/dbtina","root","1234");  

the "dbtina" is our database. the "1234" is our password. and we have configured our ip to be like that because we are using a wired connection (peer to peer).

Exception: Communications link failure    Last packet sent to the server was 0 ms ago.*  

how do i fix this?

Answer by greatmajestics for How to successfully access the database on another computer using java and jdbc and sql?


You have to configure the firewall on the database computer to allow the traffic from different computer on specific Port.

Answer by ppeterka for How to successfully access the database on another computer using java and jdbc and sql?


Open the 3306 port on the firewall of the computer where the DB is.

Answer by Bhavik Shah for How to successfully access the database on another computer using java and jdbc and sql?


Simply disable firewall. or open the port 3306 for mysql use this link if it helps

manually open port

even after doing this you might get security exception. use mysql GRANT query to give permissions.

mysql> GRANT ALL PRIVILEGES ON db_base.* TO db_user @'ip_address' IDENTIFIED BY 'db_passwd';

grant example

Answer by Ajay_Meena for How to successfully access the database on another computer using java and jdbc and sql?


Change your code accordingly:

Class.forName("com.mysql.jdbc.Driver");           con = DriverManager.getConnection("jdbc:mysql://192.168.0.1:3306/dbtina",    "root","1234");  

Answer by Manas Maity for How to successfully access the database on another computer using java and jdbc and sql?


GRANT ALL PRIVILEGES ON *.* TO 'USERNAME'@'%' IDENTIFIED BY 'PASSWORD' WITH GRANT OPTION;  


Fatal error: Call to a member function getElementsByTagName() on a non-object in D:\XAMPP INSTALLASTION\xampp\htdocs\endunpratama9i\www-stackoverflow-info-proses.php on line 72

0 comments:

Post a Comment

Popular Posts

Powered by Blogger.