方法是否要加关键字synchronized.因为我担心JDBC中的Connection、ResultSet等是非线程安全的。不知道,我的担心是否多余。代码大概是这样的。
public class Test {
public static synchronized insertStudent(Student std) {
Connection conn = ds.getConnection();
Statement st = conn.createStatemete();
st.executeUpdate("...");
....
}
}
public class Test {
public static synchronized insertStudent(Student std) {
Connection conn = ds.getConnection();
Statement st = conn.createStatemete();
st.executeUpdate("...");
....
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货