je veux transférer une connexion d'un Managed bean à un autre, ça veut dire du "ManagedBeanO" vers le "DataBaseO", mais j'ai cette erreur:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
 
An Error Occurred:
Impossible de créer le bean géré «DataBaseO». Les problèmes suivants ont été détectés : - La propriété «connectedUser» du bean géré «DataBaseO» n?existe pas.
ManagedBeanO.java

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
 
.
.
.
 
	private  Connection getConnection(String host, String port, String baseName, String user, String password) throws Exception 
        {
		// Driver Oracle
		driver = "oracle.jdbc.driver.OracleDriver";
		// URL de la connexion
		//url = "jdbc:oracle:thin:@"+host+":"+port+":"+baseName;
                url = "jdbc:oracle:thin:@"+"172.30.2.21"+":"+"1521"+":"+"PC9BIDEV";
		try {
			Class.forName(driver);
			// On obtient la connexion
			connection = DriverManager.getConnection(url, "TMA_LOGICA", "TMA_LOGICA");
			logger.info("Connection obtenue");
			// On retourne la connexion
			return connection;
		} catch (SQLException e) {
			logger.warning("Incorrect Connection Data.");
			throw new TechnicalException("No-Connexion-Established-003");
		}
		catch (ClassNotFoundException e) {
			// logger).fatal("Inexistent or Incorrect Driver.");
			throw new Exception("Driver-Not-Exist-004");
		} 
	}
 
....
DataBaseO.java

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package csl;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.io.IOException;
import java.sql.SQLException; 
import java.sql.DriverManager;
import javax.enterprise.context.ApplicationScoped;
import javax.faces.bean.*;
import javax.sql.rowset.CachedRowSet;
/**
 *
 * @author Administrateur
 */
@ManagedBean (name="DataBaseO")
@RequestScoped
 
public class DataBaseO {
 
        private static Statement statement;
 
 
        private ResultSet result; 
   @ManagedProperty(value="#{ManagedBeanO.connectedUser}")      
   private Connection  connectedUser ; // +setter     
 
 
     public ResultSet getAll() throws SQLException, IOException, InstantiationException, IllegalAccessException, ClassNotFoundException     
     {         try {  
 
                   statement = connectedUser.createStatement();             
                   Statement stmt = connectedUser.createStatement();                     
                   ResultSet result = stmt.executeQuery("SELECT * FROM all_tables");             
                   CachedRowSet crs = new com.sun.rowset.CachedRowSetImpl();             
                   crs.populate(result);             
                   return crs;         
                  }         
             finally {             
                    connectedUser.close();         
                     }      
     } 
 
 
}