我试图更改连接到我的数据库的用户,但它没有工作,我坚持使用第一个。我该怎么做?
> jsproj@1.0.0 test /Users/abhimanyuaryan/Desktop/JSProj
> jest
2018-05-08T12:40:57,551: [cli] Failed to open /Users/abhim
anyuaryan/Library/LaunchAgents/com.github.facebook.watchma
n.plist for write: Not a directory
Watchman: watchman --no-pretty get-sockname returned with
exit code=null, signal=SIGABRT, stderr= 2018-05-08T12:40:
57,551: [cli] Failed to open /Users/abhimanyuaryan/Library
/LaunchAgents/com.github.facebook.watchman.plist for write
: Not a directory
我在我的public class Model {
private String user;
private String passwd;
private String url;
private String matricule;
private static Model model;
private Connection connect;
private DoctorsModel doctorsModel;
private ConnexionModel connexionModel;
private MedicineModel medicineModel;
private VisitorsModel visitorsModel;
private ReportModel reportModel;
private NewReportModel newReportModel;
private Model(String user, String passwd){
this.user = user;
this.passwd = passwd;
url="myurl";
try {
Class.forName("com.mysql.jdbc.Driver");
System.out.println("Driver OK");
this.connect = DriverManager.getConnection(url, user, passwd);
this.connexionModel = new ConnexionModel(connect,url,user,passwd);
this.doctorsModel = new DoctorsModel(connect);
this.medicineModel = new MedicineModel(connect);
this.visitorsModel = new VisitorsModel(connect);
this.reportModel = new ReportModel(connect);
this.newReportModel = new NewReportModel(connect,matricule);
}
catch (Exception e){
Alert error = new Alert(Alert.AlertType.WARNING);
error.setTitle("Erreur");
error.setHeaderText(null);
error.setContentText("Une erreur a été rencontrée, veuillez réessayer plus tard.");
error.showAndWait();
System.exit(0);
e.printStackTrace();
}
}
public static Model getInstance()
{
if (model==null)
{
model = new Model("firstuser","passwd");
}
return model;
}
public ConnexionModel getConnexionModel()
{
return connexionModel;
}
public DoctorsModel getDoctorsModel()
{
return doctorsModel;
}
public MedicineModel getMedicineModel()
{
return medicineModel;
}
public VisitorsModel getVisitorsModel()
{
return visitorsModel;
}
public ReportModel getReportModel()
{
return reportModel;
}
public NewReportModel getNewReportModel()
{
return newReportModel;
}
public void setUser(String user)
{
this.user = user;
}
public void setPasswd(String passwd)
{
this.passwd = passwd;
}
public void setConnection()
{
try
{
connect = DriverManager.getConnection(url,user,passwd);
}
catch(Exception e)
{
e.printStackTrace();
}
}
public void getConnection()
{
System.out.println(connect);
}
public void setMatricule(String matricule)
{
this.matricule = matricule;
}
public String getMatricule(String matricule)
{
return matricule;
}}
上打电话给setConnection()
,没什么好看的,我打印出ConnectionController
之前和之后,打印出用户,密码,一切都被正确更改了......我尝试在重新设置之前关闭连接,它只是告诉我连接已关闭,我再也无法访问了。