【发布时间】:2021-04-04 11:48:22
【问题描述】:
class DB
{
private MySqlConnection connection = new MySqlConnection("server=localhost;port:3306;username=root;password=;database=users_db");
public void openConnection()
{
if (connection.State == System.Data.ConnectionState.Closed)
{
connection.Open();
}
}
public void closeConnection()
{
if (connection.State == System.Data.ConnectionState.Open)
{
connection.Close();
}
}
public MySqlConnection getConnection()
{
return getConnection();
}
}
}
它成功运行但在登录过程之后..出现异常
- System.ArgumentException: '关键字不支持。 参数名称:port:3306;username'
【问题讨论】:
-
是错字吗? 在getConnection方法中返回getConnection()?