Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package login;
- import java.sql.Connection;
- import java.sql.DriverManager;
- import java.sql.SQLException;
- /**
- * Created by Admin on 02.12.2016.
- */
- public class ConnectDB {
- private Connection connection;
- private String message = "";
- // возвращаем геттер с коннектом
- public Connection getConnection(){
- return connection;
- }
- public String getMessage(){
- return message;
- }
- public boolean conDB(String URL, String USER, String PASS){
- boolean flag;
- try {
- connection = DriverManager.getConnection(URL, USER, PASS);
- } catch (SQLException e) {
- message = "Connection Failed";
- flag = false;
- // e.printStackTrace();
- }
- if (connection != null) {
- message = "Successfully Connected";
- flag = true;
- } else {
- message = "Connection Failed";
- flag = false;
- }
- return flag;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement