JDBC基本用法
jdbc.driverClass=com.microsoft.sqlserver.jdbc.SQLServerDriver jdbc.url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=test jdbc.username=root jdbc.password=root
public static Connection getConnection() throws IOException, ClassNotFoundException, SQLException { Properties props = new Properties(); props.load(new FileInputStream("jdbc.properties")); Class.forName(props.getProperty("jdbc.driverClass")); String url = props.getProperty("jdbc.url"); String username = props.getProperty("jdbc.username"); String password = props.getProperty("jdbc.password"); return DriverManager.getConnection(url, username, password); }
DBCP
Spring
JPA
Hibernate
时间: 2024-11-11 12:44:19