我可以使用来自myclient的服务器IP地址在线使用phpmyadmin .....我正在尝试使用java代码从mysql中检索数据
这是我的代码
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package wamp; import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; /** * * @author user */ public class Wamp { /** * @param args the command line arguments */ // TODO code application logic here public static void main(String args[]) throws InstantiationException, IllegalAccessException { try{ Class.forName("com.mysql.jdbc.Driver").newInstance(); Connection con = DriverManager.getConnection("jdbc:mysql://serverip:3306/test","root",""); Statement stmt=con.createStatement(); // stmt.executeUpdate("Insert into student values(1,'abc','nagpur')"); ResultSet rs= stmt.executeQuery("Select names from sample where id=15"); rs.next(); String name= rs.getString("names"); System.out.println(name); System.out.println("DOne.."); //INSERT INTO `student`(`id`, `name`, `address`) VALUES (1,'amol','nagpur'); con.close(); } catch(ClassNotFoundException | SQLException e) { System.out.println("error"+e); } } }
我收到以下错误:
错误java.sql.SQLException:null,来自服务器的消息:“主机'user-PC.Home'不允许连接到这个MySQL服务器”