{filelink=7097}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
public class PostgreSqlConnexion
{
/*
* Cette Méthode crée une connexion à une base de données PostgreSQL
*/
public static Connection getSQLServerConnection() throws Exception
{
String driver = "postgresql.Driver";
String url = "jdbc:postgres://localhost/cours";
String username = "nom d'utilisateur";
String password = "mot de passe";
Class.forName(driver); // Facultatif
Connection conn = DriverManager.getConnection(url, username, password);
return conn;
}
}
A Voir sur le même Sujet:
- exemple java connexion base postgre
- les étapes connexion base de données java
- databasemetadata mtdata
- coonnexion a une base données en java
- les base de données etape par etape en java
- java ecrire dans une base de donnee post
- ETAPES DE CONNEXION A LA BASE
- connexion bdd postgresql java
- swing connexion bdd postgres
- exemple connect postgres to java swing