当前位置: 代码迷 >> Eclipse >> eclipse连接mysql的有关问题
  详细解决方案

eclipse连接mysql的有关问题

热度:28   发布时间:2016-04-23 11:58:01.0
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();
  }
  }
}

运行后出现下面信息,不知道是怎么了?
<ConnectionProperties>
 <PropertyCategory name="Connection/Authentication">
  <Property name="user" required="No" default="" sortOrder="-2147483647" since="all">
  The user to connect as
  </Property>
  <Property name="password" required="No" default="" sortOrder="-2147483646" since="all">
  The password to use when connecting
  </Property>
  <Property name="socketFactory" required="No" default="com.mysql.jdbc.StandardSocketFactory" sortOrder="4" since="3.0.3">
  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.
  </Property>
  <Property name="connectTimeout" required="No" default="0" sortOrder="9" since="3.0.1">
  Timeout for socket connect (in milliseconds), with 0 being no timeout. Only works on JDK-1.4 or newer. Defaults to '0'.
  </Property>
  <Property name="socketTimeout" required="No" default="0" sortOrder="10" since="3.0.1">
  Timeout on network socket operations (0, the default means no timeout).
  </Property>
  <Property name="useConfigs" required="No" default="" sortOrder="2147483647" since="3.1.5">
  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.
  </Property>
  <Property name="interactiveClient" required="No" default="false" sortOrder="alpha" since="3.1.0">
  Set the CLIENT_INTERACTIVE flag, which tells MySQL to timeout connections based on INTERACTIVE_TIMEOUT instead of WAIT_TIMEOUT
  </Property>
  <Property name="localSocketAddress" required="No" default="" sortOrder="alpha" since="5.0.5">
  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.
  相关解决方案