日期:2014-05-20 浏览次数:20815 次
public class JdbcUtil { private final static String databaseUrl = "jdbc:mysql://localhost:3306/"; private final static String databaseName = "jdbc"; private final static String databaseUser = "root"; private final static String databasePwd = "root"; private final static String driverName = "com.mysql.jdbc.Driver"; private final static String driverRegex = "/^[A-Za-z](/.)[A-Za-z](/.)[A-Za-z](/.)[A-Za-z]$/"; static { try { Pattern p = Pattern.compile(driverRegex); Matcher m = p.matcher(driverName); System.out.println("是否匹配" + m.matches()); Class.forName(driverName); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }