Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.MDB.test;
- import java.sql.*;
- /**
- * Created by res on 27.11.2016.
- */
- public class DBconnect {
- private final String URL = "jdbc:mysql://localhost:3306/test";
- private final String USER = "root";
- private final String PASSWORD = "root";
- private Connection connection;
- public DBconnect () {
- try {
- connection = DriverManager.getConnection(URL, USER, PASSWORD);
- if (!connection.isClosed()) {System.out.println("Соединение с БД установелено!");
- }
- }
- catch (SQLException e){ e.printStackTrace();}
- }
- //устанавливаем getter, чтобы могли получать наш connection
- public Connection getConnection() {
- return connection;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement