public synchronized int addDoctor(String did,String name,int age,int sex,String level,String spe,
int[] pPerDay,String phone,String section){
int res=0;
conn=DBConnection.getConnection();
try{
strSQL="select DID from doctor where DID='" + did + "'";
stmt=conn.createStatement();
rs=stmt.executeQuery(strSQL);
conn.setAutoCommit(false);
System.out.print("121323");
System.out.print("121323");
if(rs.next())
throw new IllegalArgumentException("Doctor ID '" + did + "' already exists.");

stmt=conn.createStatement();
strSQL="INSERT INTO doctor (DID,Name,Age,Sex,Level,Specialism,Phone,Password,Section) VALUES ('" +
did + "','" + name + "'," + age + "," + sex + ",'" + level + "','" + spe + "','" + phone + "','" +
did + "','" + section + "')";
stmt.addBatch(strSQL);
System.out.print("正常1111");
strSQL=
"INSERT INTO appointment (DID,SunA,SunP,MonA,MonP,TueA,TueP,WedA,WedP,ThuA,ThuP,FriA,FriP,SatA,SatP) VALUES ('" +
did + "'";
for(int i=0;i < 14;i++){
strSQL+=",";
strSQL+=pPerDay[i];
}
strSQL+=")";
stmt.addBatch(strSQL);
System.out.print("正常2222222222222222");
strSQL=
"INSERT INTO curappointment (DID,SunA,SunP,MonA,MonP,TueA,TueP,WedA,WedP,ThuA,ThuP,FriA,FriP,SatA,SatP) VALUES ('" +
did + "'";
for(int i=0;i < 14;i++){
strSQL+=",";
strSQL+=pPerDay[i];
}
strSQL+=")";
stmt.addBatch(strSQL);
System.out.print("正常222");
stmt.executeBatch();
System.out.print("正常333");
conn.commit();
res=1;

}
catch(SQLException sqle){
//Debug.log(Debug.getExceptionMsg(sqle));
conn.rollback();
System.out.print("connnnnn");
res= -1;
}
catch(IllegalArgumentException iae){
//Debug.log(Debug.getExceptionMsg(iae));
res= -2;
}
catch(Exception e){
res=0;
}
finally{
return res;
}
}