class.forname 如果不加就会报 No suitable driver found错误

public Database(String driver, String url, String userName, String userPWD,
   String autoCommit) {
  try {
   Class.forName(driver);
   m_conn = DriverManager.getConnection(url, userName, userPWD);
   m_conn.setAutoCommit(autoCommit.trim().equals("true"));
  } catch (Exception e) {
   e.printStackTrace();
  }
 } 


JDBC基础

你可能感兴趣的:(java,jdbc)