eclipse拒绝mysql,eclipse连接mysql的有关问题

当前位置:我的异常网» Eclipse » eclipse连接mysql的有关问题

eclipse连接mysql的有关问题

www.myexceptions.net  网友分享于:2015-08-26  浏览:23次

eclipse连接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 connection = DriverManager.getConnection(

"jdbc:mysql://localhost:3306/test","root","8566");

//连接URL为 jdbc:mysql//服务器地址/数据库名 ,后面的2个参数分别是登陆用户名和密码

System.out.println("Success connect Mysql server!");

Statement stmt = connection.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();

}

}

}

运行后出现下面信息,不知道是怎么了?

The user to connect as

The password to use when connecting

The name of the class that the driver should use for creating socket connections to the server. This class must implement the interface 'com.mysql.jdbc.SocketFactory' and have public no-args constructor.

Timeout for socket connect (in milliseconds), with 0 being no timeout. Only works on JDK-1.4 or newer. Defaults to '0'.

Timeout on network socket operations (0, the default means no timeout).

Load the comma-delimited list of configuration properties before parsing the URL or applying user-specified properties. These configurations are explained in the 'Configurations' of the documentation.

Set the CLIENT_INTERACTIVE flag, which tells MySQL to timeout connections based on INTERACTIVE_TIMEOUT instead of WAIT_TIMEOUT

Hostname or IP address given to explicitly configure the interface that the driver will bind the client side of the TCP/IP connection to when connecting.

文章评论

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值