Alexandre Brillant
Freelance / Indépendant

10 années d'expérience

- Consultant Java, XML
    - Expertise Java, XML
        - Service Java, XML
           - Formateur Java, XML
              - Développement Java, XML        

SIRET :
44163934100037

Port. :
(+33) 06 83 86 59 68

Tél
:
(+33) 01 64 79 05 71
FAX :
(+33) 01 64 79 05 71

Ouvrages :

ouvrage XML

Livre Java 5 TP

livre java 6


Architecture :

Unix/Linux :
UML :
SOAP :
Fiches de développement :



Articles / Developpez.com :

     

 

Connexion à une base de données avec une DataSource.

Il faut lancer un process rmid. On reference ensuite une entrée ODBC "mybase". L'accès à cette base va pouvoir se faire avec LDAP.

import java.util.Properties;
import javax.naming.Context;
import javax.naming.InitialContext;
public class JNDIDataSource {
public static void main(String[] argsthrows Exception {
Properties env = System.getProperties();
env.put("java.naming.factory.initial",
"com.sun.jndi.rmi.registry.RegistryContextFactory");
env.put("java.naming.provider.url","rmi://localhost:1099");
Context c = new InitialContextenv );
sun.jdbc.odbc.ee.DataSource ds = new sun.jdbc.odbc.ee.DataSource();
ds.setDatabaseName("mybase");
InitialContext ic = new InitialContext();
System.out.println"BIND with jdbc/DB1" );
ic.bind("jdbc/DB1",ds);
}

Exemple de code pour établir la connexion

private void ouvrirConnexion() throws SQLException, NamingException {
Properties env = System.getProperties();
env.put("java.naming.factory.initial",
"com.sun.jndi.rmi.registry.RegistryContextFactory");
env.put("java.naming.provider.url","rmi://localhost:1099");
Context c = new InitialContextenv );
DataSource ds = DataSource )c.lookup"jdbc/DB1" );
connexion = ds.getConnection();

 



Tips Java :

- Icônes multiples en swing
- datasource et jndi

Tips ASP :

- Accès BD avec MySql
- Algo de Levenshtein

Tests d'application :

- Nvu
- Demos

Tutoriaux :

- Ruby I
- Ruby II


Autre :

- Quelques photos

© 2007 Alexandre Brillant