package laboratory2; import java.util.*; import java.io.*; import java.sql.*; public class SimpleDataSource { private static String url; private static String username; private static String password; public static void init(String database) throws IOException, ClassNotFoundException, SQLException { Properties props = new Properties(); FileInputStream in = new FileInputStream(database); props.load(in); String driver = props.getProperty("jdbc.driver"); url = props.getProperty("jdbc.url"); username = props.getProperty("jdbc.username"); if (username == null) username = "root"; password = props.getProperty("jdbc.password"); if (password == null) password = "puss"; if (driver !=null) Class.forName(driver); } public static Connection getConnection() throws SQLException { return DriverManager.getConnection(url, username, password); } }