'Eclipse:GWT connect to MYSQL:error:the driver has not received any packets from the server
I'm using GWT to connect to MYSQL. But I every time I got the error as follows: com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server. I have putthe driver files to the war\WEB-INF\lib. And the driver has been load. For a normal JAVA project I can use the same code to find file in MYSQL. But why can't use the same code in GWT project?
public class GreetingServiceImpl extends RemoteServiceServlet implements GreetingService {
public String greetServer(String input) throws IllegalArgumentException {
Connection conn = null;
String url ="jdbc:mysql://localhost:3306/pcmorder";
String driver = "com.mysql.jdbc.Driver";
String user = "root";
String pass = "123456";
//String query = "SELECT id FROM tb_user WHERE username = ";
String sql=null ;
String[] namelist;
int name1=0 ;
try {
Class.forName(driver).newInstance();
System.out.println("OK");
conn = DriverManager.getConnection(url, user, pass);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
