Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class DatabaseHelper {
- public static Connection getConnection() {
- String user = ("root");
- String password = ("root");
- String url = ("jdbc:mysql://localhost:3306/users" +
- "?autoReconnect=true&useSSL=false&useLegacyDatetimeCode=false&serverTimezone=UTC");
- try {
- Class.forName("com.mysql.jdbc.Driver");
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- try {
- return DriverManager.getConnection(url, user, password);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return null;
- }
- public static Properties getConfiguration (){
- Properties properties = new Properties();
- try {
- FileInputStream in = new FileInputStream("my.properties");
- properties.load(in);
- in.close();
- return properties;
- } catch (java.io.IOException e) {
- e.printStackTrace();
- }
- return null;
- }
- public static Map getMap() {
- Map<String, String> result = new HashMap();
- result.put("hibernate.dialect", "org.hibernate.dialect.MySQLDialect");
- result.put("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
- result.put("hibernate.connection.url", "jdbc:mysql://localhost:3306/test");
- result.put("hibernate.connection.username", "root");
- result.put("hibernate.connection.password", "root");
- result.put("hibernate.show_sql", "true");
- result.put("hibernate.hbm2ddl.auto", "create");
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement