Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.sql.*;
- public class JDBCtest {
- public static void main(String[] args) {
- //URL к базе состоит из протокола:подпротокола://[хоста]:[порта_СУБД]/[БД] и других_сведений
- String url = "jdbc:postgresql://127.0.0.1:5432/test";
- Properties p = new Properties();
- p.setProperty("user", "vasya"); //Имя пользователя БД
- p.setProperty("password", "123456"); //Пароль
- p.setProperty("ssl", "true");
- Connection connection = DriverManager.getConnection(url, p);
- System.out.println("Соединение установлено");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement