首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

刚学数据库 出现的有关问题 快进来看看大师们

2013-09-11 
刚学数据库 出现的问题快进来看看大师们import java.sql.*public class GetConn {public Connection conn

刚学数据库 出现的问题 快进来看看大师们
import java.sql.*;
public class GetConn {
public Connection conn=null;
  public void getconnection(){
  try{
  //Class.forName("org.gjt.mm.mysql.Driver");

  String url=("jdbc:mysql://localhosst:3306/gh");
  String user="root";
  String password="123456";
  conn=DriverManager.getConnection(url,user,password);
  if(conn!=null){
  System.out.println("数据库连接成功");
  }
  }
  catch(Exception e){
  System.out.println(e.getMessage());
  }
  return ;
  }
  public static void main(String args[]){
  GetConn ob=new GetConn();
  ob.getconnection();
  }
}
连接时候出现的提示:
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.
本人用得是校园网 没有什么关系的吧 什么防火墙软件都关闭了

[解决办法]

Java code
String url=("jdbc:mysql://localhost:3306/gh");//是localhost,不是localhosst
[解决办法]
探讨
Java code


String url=("jdbc:mysql://localhost:3306/gh");//是localhost,不是localhosst

[解决办法]
探讨

Java code

String url=("jdbc:mysql://localhost:3306/gh");//是localhost,不是localhosst

[解决办法]
对了如果楼主学校用的是Dr.com的话 那以后编程中会遇到很多问题的?如果有些问题实在解决不了那就关了Dr.com 然后修复LSP即可
我的异常网推荐解决方案:The driver has not received any packets from the server.,http://www.myexception.cn/j2ee/345243.html

热点排行