Connexion postgresql avec java
Fermé
odette1
Messages postés
46
Date d'inscription
mardi 7 avril 2009
Statut
Membre
Dernière intervention
6 avril 2011
-
21 févr. 2010 à 23:41
odette1 Messages postés 46 Date d'inscription mardi 7 avril 2009 Statut Membre Dernière intervention 6 avril 2011 - 22 févr. 2010 à 19:32
odette1 Messages postés 46 Date d'inscription mardi 7 avril 2009 Statut Membre Dernière intervention 6 avril 2011 - 22 févr. 2010 à 19:32
A voir également:
- Connexion postgresql avec java
- Formate pour taxer client connexion ✓ - Forum Matériel informatique
- Instagram connexion - Guide
- Facebook connexion - Guide
- Gmail connexion - Guide
- Jeux java itel ✓ - Forum Jeux vidéo
2 réponses
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.postgresql.Driver;
public class Connexion {
// postgres njara //localhost:5432/postgres
private Connection conn;
public Connexion () throws SQLException{
Driver d;
try {
d = (Driver) Class.forName("org.postgresql.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432" , "postgres[NomBD]", "postgres[password]");
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public void FermerConnexion() throws SQLException {
conn.rollback();
conn.close();
System.out.println("Connexion fermée" + " " + conn);
}
public void commit()throws SQLException {
conn.commit();
}
public void rollback() throws SQLException {
conn.rollback();
}
public Connection getConnection(){
return conn;
}
}
import java.sql.DriverManager;
import java.sql.SQLException;
import org.postgresql.Driver;
public class Connexion {
// postgres njara //localhost:5432/postgres
private Connection conn;
public Connexion () throws SQLException{
Driver d;
try {
d = (Driver) Class.forName("org.postgresql.Driver").newInstance();
conn = DriverManager.getConnection("jdbc:postgresql://localhost:5432" , "postgres[NomBD]", "postgres[password]");
} catch (InstantiationException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public void FermerConnexion() throws SQLException {
conn.rollback();
conn.close();
System.out.println("Connexion fermée" + " " + conn);
}
public void commit()throws SQLException {
conn.commit();
}
public void rollback() throws SQLException {
conn.rollback();
}
public Connection getConnection(){
return conn;
}
}
odette1
Messages postés
46
Date d'inscription
mardi 7 avril 2009
Statut
Membre
Dernière intervention
6 avril 2011
1
22 févr. 2010 à 19:32
22 févr. 2010 à 19:32
merci pour votre aide, mais je comprends pas pourquoi on m'affiche plusieurs erreurs!!
Autre chose, lorsque je compile on m'affiche ce qui suit:
PostgreSQL 8.4 JDBC4 (build 701)
Found in: jar:file:/C:/Users/odette/Documents/Downloads/postgresql-8.4-701.jdbc4.jar!/org/postgresql/Driver.class
Je voudrais savoir la signification de ceci.
Merci beaucoup
Autre chose, lorsque je compile on m'affiche ce qui suit:
PostgreSQL 8.4 JDBC4 (build 701)
Found in: jar:file:/C:/Users/odette/Documents/Downloads/postgresql-8.4-701.jdbc4.jar!/org/postgresql/Driver.class
Je voudrais savoir la signification de ceci.
Merci beaucoup