eclipse和JAVA如何用虚拟机的MySQL数据库,为什么失败,我收到ping得通虚拟机的中系统的ip
麻烦大师看看,我弄了好久,弄不成
192.......135是虚拟机中的ip
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
Class.forName("com.mysql.jdbc.Driver");
Connection conn=DriverManager.getConnection("jdbc:mysql://192.......135:3306/mycs","root","adfsfa");
Statement stmt=conn.createStatement();
stmt.executeUpdate("insert into cs values(1,'aa',2)");
}catch(ClassNotFoundException e){
e.printStackTrace();
}catch(SQLException e){
e.printStackTrace();
}
}