Cela se choisit, sauf erreur, au moment où tu donnes l'url de connexion au driver:
DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:mydb", "user", "pass")
Maintenant, il peut être préférable d'utiliser un DataSource, configuré au niveau du container, via jndi:
1 2 3 4 5 6
|
Context ctx = new InitialContext();
DataSource ds = (DataSource)ctx.lookup("java:comp/env/jdbc/" + jndiName);
if (ds == null) throw new RuntimeException("Datasource not found");
Connection conn = ds.getConnection();
if (conn == null) throw new RuntimeException("Could not get connection"); |
... et là l'url se configure au niveau du container, et plus de la webapp
Partager