IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JDBC Java Discussion :

Appele d'une procédure stocké à partir d'une base de données oracle


Sujet :

JDBC Java

  1. #1
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 26
    Points : 20
    Points
    20
    Par défaut Appele d'une procédure stocké à partir d'une base de données oracle
    Comment récuperé le résultat d'une procédure stocké à partir de la base de données .sachant que j'ai utilise le jdbc et le type de retour cest Row .j'ai fait un essai ca pas marhcé voici le code
    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
    49
    50
    51
    52
    53
    54
    55
    56
     
     
      Object[] returnObject = new Object[2];
    	    CallableStatement cs ;
     
    	    try {
                Connection con = getConnection(dataSource);
     
             try {
     
     
     
             	cs = con.prepareCall("{? = call Rech_Tiers(?,?)}");
    //Je sais quelles Type utilisé .J'ai un Row en retour.
                cs.registerOutParameter(1,Types.JAVA_OBJECT);
                cs.setString(2,TypeId);
                cs.setString(3,Id);
                cs.execute();
                ResultSet res = (ResultSet)cs.getObject(1);
     
                Tiers tiers = new Tiers();
     
               if(res.next())
                {
               	tiers.setDENOMINATION(res.getString(2));
                tiers.setTITRE(res.getString(3));
                tiers.setDATE_NAISSANCE(res.getString(6));
                tiers.setCODE_GROUPE(res.getString(7));
                tiers.setCODE_PAYS(res.getString(8));
                tiers.setCODE_SECTEUR_ECONOMIQUE(res.getString(9));
                tiers.setCODE_REGION_ECONOMIQUE(res.getString(10));
                tiers.setCODE_AGENT_ECONOMIQUE(res.getString(11));
     
               }
               else
               {
               	tiers=null;
               	}
     
                returnObject[0] = tiers;
     
     
             } catch (Exception ex) {
     
                 ex.printStackTrace();
                 //-->log errors
             } finally {
                 con.close();
             }
         } catch (SQLException sqlex) {
            sqlex.printStackTrace();
             //-->log errors
         }
         return returnObject;
     
    	   }

  2. #2
    in
    in est déconnecté
    Membre expérimenté Avatar de in
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 612
    Points : 1 718
    Points
    1 718
    Par défaut
    Citation Envoyé par jalalos
    J'ai fait un essai ca pas marhcé
    C'est à dire ?
    "If email had been around before the telephone was invented, people would have said, 'Hey, forget email! With this new telephone invention I can actually talk to people!"

    Besoin d'une nouvelle méthode pour développer ? -> http://www.la-rache.com/

  3. #3
    Membre à l'essai
    Profil pro
    Inscrit en
    Janvier 2007
    Messages
    26
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2007
    Messages : 26
    Points : 20
    Points
    20
    Par défaut
    Càd ce code la n'as pas marché car j'ai pas spécifié le bon type de retour ,la fonction nous retourne un Row au niveau d'oracle .et je ne sais pas quel type utilisé au niveau de java j'ai essayè avec OBject
    cs.registerOutParameter(1,Types.JAVA_OBJECT);
    mais y a des erreurs .
    voici les errreurs :

    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
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R java.sql.SQLException: Type de colonne non valide
    	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    	at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
    	at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:225)
    	at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:350)
    	at com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement.registerOutParameter(WSJdbcCallableStatement.java:626)
    	at com.bfc.cg.dao.GageDAO.chercheTiers(GageDAO.java:1071)
    	at com.bfc.cg.buz.GageBuz.chercheTiers(GageBuz.java:99)
    	at com.bfc.cg.page.GagePage.chercheTiers(GagePage.java:2108)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
    	at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
    	at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:127)
    	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:73)
    	at javax.faces.component.UICommand.broadcast(UICommand.java:312)
    	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:302)
    	at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:342)
    	at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:81)
    	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:201)
    	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
    	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
    	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1173)
    	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
    	at com.bfc.cg.filter.RefreshFilter.doFilter(RefreshFilter.java:108)
    	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
    	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    	at com.bfc.cg.filter.OperFilter.doFilter(OperFilter.java:51)
    	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
    	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    	at com.bfc.cg.filter.AccessFilter.doFilter(AccessFilter.java:54)
    	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
    	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
    	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:80)
    	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1657)
    	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
    	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
    	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
    	at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94)
    	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
    	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
    	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
    	at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
    	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))
     
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:168)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:210)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:273)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at oracle.jdbc.driver.OracleStatement.get_internal_type(OracleStatement.java:4560)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:225)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at oracle.jdbc.driver.OracleCallableStatement.registerOutParameter(OracleCallableStatement.java:350)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.rsadapter.jdbc.WSJdbcCallableStatement.registerOutParameter(WSJdbcCallableStatement.java:626)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.bfc.cg.dao.GageDAO.chercheTiers(GageDAO.java:1071)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.bfc.cg.buz.GageBuz.chercheTiers(GageBuz.java:99)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.bfc.cg.page.GagePage.chercheTiers(GagePage.java:2108)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:127)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:73)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at javax.faces.component.UICommand.broadcast(UICommand.java:312)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:302)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:342)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:81)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:201)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:91)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1212)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.service(ServletWrapper.java:1173)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:92)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.bfc.cg.filter.RefreshFilter.doFilter(RefreshFilter.java:108)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.bfc.cg.filter.OperFilter.doFilter(OperFilter.java:51)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.bfc.cg.filter.AccessFilter.doFilter(AccessFilter.java:54)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:142)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:77)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.ServletWrapper.handleRequest(ServletWrapper.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.servlet.CacheServletWrapper.handleRequest(CacheServletWrapper.java:80)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.WebContainer.handleRequest(WebContainer.java:1657)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.webcontainer.channel.WCChannelLink.ready(WCChannelLink.java:77)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleDiscrimination(HttpInboundLink.java:421)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpInboundLink.handleNewInformation(HttpInboundLink.java:367)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.http.channel.inbound.impl.HttpICLReadCallback.complete(HttpICLReadCallback.java:94)
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.requestComplete(WorkQueueManager.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.attemptIO(WorkQueueManager.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.WorkQueueManager.workerRun(WorkQueueManager.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.tcp.channel.impl.WorkQueueManager$Worker.run(WorkQueueManager.java(Compiled Code))
    [10/04/07 10:21:27:969 GMT] 0000003b SystemErr     R 	at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java(Compiled Code))

  4. #4
    in
    in est déconnecté
    Membre expérimenté Avatar de in
    Profil pro
    Inscrit en
    Avril 2003
    Messages
    1 612
    Détails du profil
    Informations personnelles :
    Localisation : France, Finistère (Bretagne)

    Informations forums :
    Inscription : Avril 2003
    Messages : 1 612
    Points : 1 718
    Points
    1 718
    Par défaut
    tu n'a rien essayé d'autre genre ARRAY ?

    N'est-il pas possible de définir un autre type de retour de la procédure SQL ?
    "If email had been around before the telephone was invented, people would have said, 'Hey, forget email! With this new telephone invention I can actually talk to people!"

    Besoin d'une nouvelle méthode pour développer ? -> http://www.la-rache.com/

Discussions similaires

  1. Réponses: 6
    Dernier message: 22/12/2011, 16h26
  2. Réponses: 6
    Dernier message: 08/09/2010, 17h25
  3. Réponses: 11
    Dernier message: 03/06/2010, 10h39
  4. Réponses: 0
    Dernier message: 11/09/2009, 18h25
  5. Comment creer une procédure stockée à partir d'un code VBA?
    Par Alcor020980 dans le forum Connexion aux bases de données
    Réponses: 4
    Dernier message: 24/05/2005, 19h55

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo