-3
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package inventory;
import java.net.InetAddress;
import java.sql.Connection;
import java.sql.DriverManager;
/**
*
* @author Imantha
*/
public class dbcon {
public static Connection createmyConnection() throws Exception{
InetAddress ip=InetAddress.getLocalHost();
String s=ip.getHostAddress();
Class.forName("com.mysql.jdbc.Driver");
Connection c = DriverManager.getConnection("jdbc:mysql://localHost:3306/inventory","root","123");
return c;
}
}
我該如何使用ip addre從InerAddress中找到通過JDBC連接MySQL?如何使用IP地址(通過InetAddress)通過JDBC與MySQL建立連接?
我要替換本地主機和加s(其捕獲IP地址)