- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Java – MySQL connection with ipAddress
Set the JDBC MySQL URL in the DriverManager.getConnection to connect with IP Address. Following is the code to connect using IP Address −
Example
import java.sql.Connection; import java.sql.DriverManager; public class JavaIP { public static void main(String[] args) { String hostURL = "jdbc:mysql://192.168.43.144:3306/web?useSSL=false"; Connection con = null; try { con = DriverManager.getConnection(hostURL, "root", "123456"); System.out.println("connection successful via ip address"); } catch (Exception e) { e.printStackTrace(); } } }
Output
This will produce the following output −
connection successful via ip address
Here is the snapshot of the output −
Advertisements