Eclipse下java连接Mysql控制台中出现了如下提示<ConnectionProperties>
<PropertyCategory name="Connection/Authentication">
<Property name="user" required="No" default="" sortOrder="-2147483647" since="all versions">
The user to connect as
</Property>
<Property name="password" required="No" default="" sortOrder="-2147483646" since="all versions">
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), wi我的代码如下:
import java.sql.*;
public class GetConn{
public Connection conn=null;
public Connection getConnection() throws ClassNotFoundException{
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/test";
String user="root";
String passWord="family";
conn=DriverManager.getConnection(url,user,passWord);
if(conn!=null){
System.out.println("数据库连接成功");
}
}catch(SQLException e){
e.printStackTrace();
}
return conn;
}
public static void main(String[] args) throws ClassNotFoundException {
GetConn getConn=new GetConn();
getConn.getConnection();
环境变量我也配了,包也导入工程中了,请问是哪个地方出现了问题
<PropertyCategory name="Connection/Authentication">
<Property name="user" required="No" default="" sortOrder="-2147483647" since="all versions">
The user to connect as
</Property>
<Property name="password" required="No" default="" sortOrder="-2147483646" since="all versions">
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), wi我的代码如下:
import java.sql.*;
public class GetConn{
public Connection conn=null;
public Connection getConnection() throws ClassNotFoundException{
try{
Class.forName("com.mysql.jdbc.Driver");
String url="jdbc:mysql://localhost:3306/test";
String user="root";
String passWord="family";
conn=DriverManager.getConnection(url,user,passWord);
if(conn!=null){
System.out.println("数据库连接成功");
}
}catch(SQLException e){
e.printStackTrace();
}
return conn;
}
public static void main(String[] args) throws ClassNotFoundException {
GetConn getConn=new GetConn();
getConn.getConnection();
环境变量我也配了,包也导入工程中了,请问是哪个地方出现了问题
解决方案 »
- A机器IP是192.168.78.101,B机器IP是210.76.32.102,现在在A机器上远程为B机器安装MYSQL,怎样安装?安装的时候怎样设置?
- 在windows程序中用system不能执行mysql和mysqldump命令,为什么?
- 请教循环建表语句。
- 这种稍微复杂点的SQL语句能实现么?
- 大家帮我看看这个sql语句有什么问题?
- MySQL的ODBC与ADO连接,是否支持一次执行多条SQL语句?
- 数据统计请教?
- LINUX下的MySQL,默认不允许非本机连接,该如何解决?
- 筛出选择相同产品的用户,怎样写sql?
- 急:mysql查询分时段(24小时)的用户数量
- MySql 存储过程输入参数的值为中文时出错,错误号1366
- json数据 查询
说明,你的程序未执行“conn=DriverManager.getConnection(url,user,passWord);”
但能找到驱动。
最大的可能是数据库未开启,
核对端口;
先自己ping一下。