eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢

eclipse导入jar包连接mysql数据库出错,帮帮忙~谢谢
我用的是jdk1.7
mysql 5.6
在程序中导入mysql-connector-java-5.1.25.jar
百度了很久就是没办法解决,希望大家能帮帮忙~~~,谢谢。
代码是网上提供的,这里引用一下。
http://www.cnblogs.com/fnng/archive/2011/07/18/2110023.html

eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢

eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢



import java.sql.*;
public class MysqlJdbc {
  public static void main(String args[]) {
    try {
      Class.forName("com.mysql.jdbc.Driver");     //加载MYSQL JDBC驱动程序   
      //Class.forName("org.gjt.mm.mysql.Driver");
     System.out.println("Success loading Mysql Driver!");
    }
    catch (Exception e) {
      System.out.print("Error loading Mysql Driver!");
      e.printStackTrace();
    }
    try {
      Connection connect = DriverManager.getConnection(
          "jdbc:mysql://localhost:3306/test","root","123");
           //连接URL为   jdbc:mysql//服务器地址/数据库名  ,后面的2个参数分别是登陆用户名和密码

      System.out.println("Success connect Mysql server!");
      Statement stmt = connect.createStatement();
      ResultSet rs = stmt.executeQuery("select * from user");
                                                              //user 为你表的名称
      while (rs.next()) {
        System.out.println(rs.getString("name"));
      }
    }
    catch (Exception e) {
      System.out.print("get data error!");
      e.printStackTrace();
    }
  }
}

文章评论

eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
科技史上最臭名昭著的13大罪犯
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员的样子
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
Google伦敦新总部 犹如星级庄园
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
每天工作4小时的程序员
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
看13位CEO、创始人和高管如何提高工作效率
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
初级 vs 高级开发者 哪个性价比更高?
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序猿的崛起——Growth Hacker
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员最害怕的5件事 你中招了吗?
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
10个帮程序员减压放松的网站
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
中美印日四国程序员比较
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员应该关注的一些事儿
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员周末都喜欢做什么?
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
编程语言是女人
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
为什么程序员都是夜猫子
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
那些性感的让人尖叫的程序员
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
当下全球最炙手可热的八位少年创业者
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
Java 与 .NET 的平台发展之争
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
什么才是优秀的用户界面设计
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
写给自己也写给你 自己到底该何去何从
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
旅行,写作,编程
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
亲爱的项目经理,我恨你
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
“肮脏的”IT工作排行榜
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员和编码员之间的区别
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
10个调试和排错的小建议
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员必看的十大电影
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
老美怎么看待阿里赴美上市
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员眼里IE浏览器是什么样的
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
2013年美国开发者薪资调查报告
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
Web开发人员为什么越来越懒了?
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
要嫁就嫁程序猿—钱多话少死的早
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
为啥Android手机总会越用越慢?
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
我跳槽是因为他们的显示器更大
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
不懂技术不要对懂技术的人说这很容易实现
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员的一天:一寸光阴一寸金
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
如何成为一名黑客
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
漫画:程序员的工作
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
Web开发者需具备的8个好习惯
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
代码女神横空出世
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
团队中“技术大拿”并非越多越好
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
程序员的鄙视链
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
做程序猿的老婆应该注意的一些事情
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
聊聊HTTPS和SSL/TLS协议
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
如何区分一个程序员是“老手“还是“新手“?
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
“懒”出效率是程序员的美德
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
一个程序员的时间管理
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
那些争议最大的编程观点
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
我的丈夫是个程序员
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
Java程序员必看电影
eclipse导入jar包连接mysql数据库出错,帮帮忙~多谢
我是如何打败拖延症的