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

Oracle Discussion :

Passer un objet à une procédure ORACLE


Sujet :

Oracle

  1. #1
    Membre à l'essai
    Inscrit en
    Septembre 2005
    Messages
    36
    Détails du profil
    Informations forums :
    Inscription : Septembre 2005
    Messages : 36
    Points : 19
    Points
    19
    Par défaut Passer un objet à une procédure ORACLE
    bonjour;

    en java comme j'ai un nombre conséquent de données à passer à ma procédure SQL oracle j'ai décider de passer un objet en paramètre.

    voici mon code :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    			ps = this.prepareCall("{call INSERT_SAA_EVT_OBJ (?)}");
     
    			// Create an oracle.sql.STRUCT object to hold the values 
    			Object[] object1Values = new Object[]{"ooo"  ,   new Integer(2)};
    			StructDescriptor structDesc =
    				StructDescriptor.createDescriptor("COMPTE_RENDU_EVT_SAA_OBJ", ps.getConnection());
    			STRUCT object1 =
    				new STRUCT(structDesc, ps.getConnection(), object1Values);
     
    			// Set the values to insert
    			ps.setObject(1, object1);
    			ps.executeUpdate();
    au niveau de ma base oracle j'ai créé mon type COMPTE_RENDU_EVT_SAA_OBJ

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    CREATE OR REPLACE TYPE COMPTE_RENDU_EVT_SAA_OBJ AS OBJECT
    (
    IDENTIFIANT_UNIQUE_TRANSACTION VARCHAR2(15)  NULL,
    CODE_EVENEMENT NUMBER(2) NULL)
    J'ai créé un synonym public sur cet objet (créé dans un compte utilisateur) déclaré des GRANT EXECUTE également.

    la ligne du createDescriptor me génère l'execption:
    java.sql.SQLException: Type non déterminé: get_next_type

    des idées car une recherche sur google n'a rien donnée !!

    (je viens de regarder si je voyais sous sqltools mon type avec l'utilisateur java et non !! c'est donc ca mais je ne comprend pas)

  2. #2
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Peut-être ceci pourra vous être utile:

    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
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    /*
     * This example demonstrates the Oracle 9i inheritance feature. It 
     * demonstrates the access of subtype objects by using JDBC default
     * mapping.
     *
     * This example creates the object types hierarchy as follows --
     *
     *   Person_t  -+- Employee_t
     *              |
     *              +- Student_t  -- ParttimeStudent_t
     *  
     * and a object table of Person_t.
     *
     * This example inserts the Person_t, Employee_t, Student_t and
     * ParttimeStudent_t objects into the object table, and selects 
     * the objects and prints out their values.
     */
     
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
     
    public class Inheritance3
    {
      public static void main (String args []) throws Exception
      {
        // Load the Oracle JDBC driver
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
     
        String urlDefault = "jdbc:oracle:oci8:@";
        String url = null;
        try 
        {
          url = System.getProperty("JDBC_URL");
        } 
        catch (Exception e) 
        {
          // If there is any security exception, ignore it
          // and use the default
        }
        finally
        {
          if (url == null) url = urlDefault;
        }
     
        // Connect to the database
        Connection conn = DriverManager.getConnection (url, "scott", "tiger");
     
        // Create the object types and the database table
        createTables (conn);   
     
        // Insert Person_t, Student_t, ParttimeStudent_t and Employee_t
        // objects into the database.
        insert (conn);
     
        // Select the objects previously inserted
        select (conn);
     
        // Remove the objects previously created in the database
        cleanup (conn);
     
        // Disconnect
        conn.close ();
      }
     
      /**
       * Create the database data structure to be used by this example.
       */ 
      public static void createTables (Connection conn) throws SQLException
      {
        // Remove database data created by this example
        cleanup (conn);
     
        // Create a Statement
        Statement stmt = conn.createStatement ();
     
        // Create a database object type "Person_t".
        stmt.execute ("CREATE TYPE Person_t AS OBJECT       "+
                      "(  ssn NUMBER,                       "+
                      "   name VARCHAR2(30),                "+
                      "   address VARCHAR2(100)             "+
                      ") NOT FINAL");
     
        // Create a database object type "Student_t" that inherits 
        // "Person_t".
        stmt.execute ("CREATE TYPE Student_t UNDER Person_t "+
                      "(  deptid NUMBER,                    "+
                      "   major VARCHAR2(30)                "+
                      ") NOT FINAL");
     
        // Create a database object type "Employee_t" that inherits
        // "Person_t".
        stmt.execute ("CREATE TYPE Employee_t UNDER Person_t"+
                      "(  empid NUMBER,                     "+
                      "   mgr VARCHAR2(30)                  "+
                      ")");
     
        // Create a database object type "PartTimeStudent_t" that
        // inherits "Student_t".
        stmt.execute ("CREATE TYPE PartTimeStudent_t UNDER Student_t"+
                      "(  numhours NUMBER                   "+
                      ")");
     
        // Create a database table
        stmt.execute ("CREATE TABLE PersonTab of Person_t");
     
        // Close the statement
        stmt.close ();
      }
     
      /**
       * Remove database data created by this example
       */
      public static void cleanup (Connection conn) throws SQLException
      {
        // Create a Statement
        Statement stmt = conn.createStatement ();
     
        try
        {
          stmt.execute ("drop table PersonTab");
        }
        catch (SQLException e)
        {
          // An exception could be raised here if the table did not exist already.
        }
     
        try { stmt.execute ("drop type Employee_t"); } catch (SQLException e) {}
        try { stmt.execute ("drop type ParttimeStudent_t"); } catch (SQLException e) {}
        try { stmt.execute ("drop type Student_t"); } catch (SQLException e) {}
        try { stmt.execute ("drop type Person_t"); } catch (SQLException e) {}
     
        // Close the statement
        stmt.close ();
      }
     
      /**
       * This method inserts Person_t, Student_t, ParttimeStudent_t
       * and Employee_t objects into the PersonTab table. This 
       * demonstrates the column substitutablity feature of the 
       * Oracle 9i database.
       */ 
      public static void insert (Connection conn) throws SQLException
      {
     
        // Prepare the insert statement
        PreparedStatement pstmt = 
          conn.prepareStatement ("insert into PersonTab values (?)");
     
        // A place holder for Person_t objects 
        STRUCT person = null;
     
        // Create and insert a Person_t object into the database
        {
          // Obtain the Person_t type descriptor
          StructDescriptor personDesc = 
            StructDescriptor.createDescriptor ("SCOTT.PERSON_T", conn);
     
          // Prepare the Person_t attributes
          Datum[] personAttrs = 
          {
            new NUMBER (1001), 
            new CHAR ("Scott", null), 
            new CHAR ("SF", null)
          };
     
          // Create a Person_t object
          person = new STRUCT (personDesc, conn, personAttrs);
     
          // Bind the Person_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a Person_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Create and insert a Student_t object into the database
        {
          // Obtain the Student_t type descriptor
          StructDescriptor studentDesc = 
            StructDescriptor.createDescriptor ("SCOTT.STUDENT_T", conn);
     
          // Prepare the Student_t attributes
          Datum[] studentAttrs = 
          {
            new NUMBER (1002), 
            new CHAR ("Peter", null), 
            new CHAR ("NY", null),
            new NUMBER (100), 
            new CHAR ("EE", null)
          };
     
          // Create a Student_t object
          person = new STRUCT (studentDesc, conn, studentAttrs);
     
          // Bind the Student_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a Student_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Create and insert a ParttimeStudent_t object into the database
        {
          // Obtain the ParttimeStudent_t type descriptor
          StructDescriptor parttimestudentDesc = 
            StructDescriptor.createDescriptor ("SCOTT.PARTTIMESTUDENT_T", conn);
     
          // Prepare the ParttimeStudent_t attributes
          Datum[] parttimestudentAttrs = 
          {
            new NUMBER (1003), 
            new CHAR ("John", null), 
            new CHAR ("LA", null),
            new NUMBER (101), 
            new CHAR ("CS", null), 
            new NUMBER (20)
          };
     
          // Create ParttimeStudent_t object
          person = new STRUCT (parttimestudentDesc, conn, parttimestudentAttrs);
     
          // Bind the ParttimeStudent_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion and print the update count
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a ParttimeStudent_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Create and insert a Employee_t object into the database
        {
          // Obtain the Employee_t type descriptor
          StructDescriptor employeeDesc = 
            StructDescriptor.createDescriptor ("SCOTT.EMPLOYEE_T", conn);
     
          // Prepare the Employee_t attributes
          Datum[] employeeAttrs = 
          {
            new NUMBER (1004), 
            new CHAR ("David", null),
            new CHAR ("SF", null), 
            new NUMBER (1111), 
            new CHAR ("SCOTT", null) 
          };
     
          // Create a Employee_t object
          person = new STRUCT (employeeDesc, conn, employeeAttrs);
     
          // Bind the Employee_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a Employee_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Close the PreparedStatment
        pstmt.close ();
      }
     
      /**
       * This method queries the database PersonTab table and print the
       * object table values.
       */
      public static void select (Connection conn) throws SQLException
      {
        System.out.println ("List the Person_t objects : ");
     
        // Create a statement
        Statement stmt = conn.createStatement ();
     
        // Execute the query
        ResultSet rset = stmt.executeQuery ("select value(t) from PersonTab t");
     
        // Iterate the result set
        while (rset.next ())
        {
          // The object value can be a Person_t, Student_t, ParttimeStudent_t
          // or Employee_t.
          STRUCT person = (STRUCT) rset.getObject (1);
     
          // Obtain the type descriptor 
          StructDescriptor desc = person.getDescriptor ();
     
          // Obtain the type metadata to display the attribute names
          ResultSetMetaData md = desc.getMetaData ();
     
          // Create a StringBuffer to save the attribute information
          StringBuffer sbuf = new StringBuffer ();
     
          // Write the SQL type name to hte StringBuffer
          sbuf.append (person.getSQLTypeName()+": ");
     
          // Access the Person_t attributes
          Datum[] attrs = person.getOracleAttributes ();
     
          // Iterate the attributes
          for (int i=0; i<attrs.length; i++)
          {      
            // For each attribute, we first write the attribute name 
            // the string buffer
            sbuf.append (md.getColumnName(i+1)+"=");
     
            // Write the attribute value to the string buffer
            sbuf.append (attrs[i].stringValue()+" ");
          }
          // Print the stringBuffer value
          System.out.println (sbuf.toString());
        }
     
        // Close the result set
        rset.close ();
     
        // Close the statement
        stmt.close ();
      }
    }
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  3. #3
    Membre à l'essai
    Inscrit en
    Septembre 2005
    Messages
    36
    Détails du profil
    Informations forums :
    Inscription : Septembre 2005
    Messages : 36
    Points : 19
    Points
    19
    Par défaut
    Citation Envoyé par SheikYerbouti
    Peut-être ceci pourra vous être utile:

    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
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    282
    283
    284
    285
    286
    287
    288
    289
    290
    291
    292
    293
    294
    295
    296
    297
    298
    299
    300
    301
    302
    303
    304
    305
    306
    307
    308
    309
    310
    311
    312
    313
    314
    315
    316
    317
    318
    319
    320
    321
    322
    323
    324
    325
    326
    327
    328
    /*
     * This example demonstrates the Oracle 9i inheritance feature. It 
     * demonstrates the access of subtype objects by using JDBC default
     * mapping.
     *
     * This example creates the object types hierarchy as follows --
     *
     *   Person_t  -+- Employee_t
     *              |
     *              +- Student_t  -- ParttimeStudent_t
     *  
     * and a object table of Person_t.
     *
     * This example inserts the Person_t, Employee_t, Student_t and
     * ParttimeStudent_t objects into the object table, and selects 
     * the objects and prints out their values.
     */
     
    import java.sql.*;
    import oracle.sql.*;
    import oracle.jdbc.*;
     
    public class Inheritance3
    {
      public static void main (String args []) throws Exception
      {
        // Load the Oracle JDBC driver
        DriverManager.registerDriver(new oracle.jdbc.OracleDriver());
     
        String urlDefault = "jdbc:oracle:oci8:@";
        String url = null;
        try 
        {
          url = System.getProperty("JDBC_URL");
        } 
        catch (Exception e) 
        {
          // If there is any security exception, ignore it
          // and use the default
        }
        finally
        {
          if (url == null) url = urlDefault;
        }
     
        // Connect to the database
        Connection conn = DriverManager.getConnection (url, "scott", "tiger");
     
        // Create the object types and the database table
        createTables (conn);   
     
        // Insert Person_t, Student_t, ParttimeStudent_t and Employee_t
        // objects into the database.
        insert (conn);
     
        // Select the objects previously inserted
        select (conn);
     
        // Remove the objects previously created in the database
        cleanup (conn);
     
        // Disconnect
        conn.close ();
      }
     
      /**
       * Create the database data structure to be used by this example.
       */ 
      public static void createTables (Connection conn) throws SQLException
      {
        // Remove database data created by this example
        cleanup (conn);
     
        // Create a Statement
        Statement stmt = conn.createStatement ();
     
        // Create a database object type "Person_t".
        stmt.execute ("CREATE TYPE Person_t AS OBJECT       "+
                      "(  ssn NUMBER,                       "+
                      "   name VARCHAR2(30),                "+
                      "   address VARCHAR2(100)             "+
                      ") NOT FINAL");
     
        // Create a database object type "Student_t" that inherits 
        // "Person_t".
        stmt.execute ("CREATE TYPE Student_t UNDER Person_t "+
                      "(  deptid NUMBER,                    "+
                      "   major VARCHAR2(30)                "+
                      ") NOT FINAL");
     
        // Create a database object type "Employee_t" that inherits
        // "Person_t".
        stmt.execute ("CREATE TYPE Employee_t UNDER Person_t"+
                      "(  empid NUMBER,                     "+
                      "   mgr VARCHAR2(30)                  "+
                      ")");
     
        // Create a database object type "PartTimeStudent_t" that
        // inherits "Student_t".
        stmt.execute ("CREATE TYPE PartTimeStudent_t UNDER Student_t"+
                      "(  numhours NUMBER                   "+
                      ")");
     
        // Create a database table
        stmt.execute ("CREATE TABLE PersonTab of Person_t");
     
        // Close the statement
        stmt.close ();
      }
     
      /**
       * Remove database data created by this example
       */
      public static void cleanup (Connection conn) throws SQLException
      {
        // Create a Statement
        Statement stmt = conn.createStatement ();
     
        try
        {
          stmt.execute ("drop table PersonTab");
        }
        catch (SQLException e)
        {
          // An exception could be raised here if the table did not exist already.
        }
     
        try { stmt.execute ("drop type Employee_t"); } catch (SQLException e) {}
        try { stmt.execute ("drop type ParttimeStudent_t"); } catch (SQLException e) {}
        try { stmt.execute ("drop type Student_t"); } catch (SQLException e) {}
        try { stmt.execute ("drop type Person_t"); } catch (SQLException e) {}
     
        // Close the statement
        stmt.close ();
      }
     
      /**
       * This method inserts Person_t, Student_t, ParttimeStudent_t
       * and Employee_t objects into the PersonTab table. This 
       * demonstrates the column substitutablity feature of the 
       * Oracle 9i database.
       */ 
      public static void insert (Connection conn) throws SQLException
      {
     
        // Prepare the insert statement
        PreparedStatement pstmt = 
          conn.prepareStatement ("insert into PersonTab values (?)");
     
        // A place holder for Person_t objects 
        STRUCT person = null;
     
        // Create and insert a Person_t object into the database
        {
          // Obtain the Person_t type descriptor
          StructDescriptor personDesc = 
            StructDescriptor.createDescriptor ("SCOTT.PERSON_T", conn);
     
          // Prepare the Person_t attributes
          Datum[] personAttrs = 
          {
            new NUMBER (1001), 
            new CHAR ("Scott", null), 
            new CHAR ("SF", null)
          };
     
          // Create a Person_t object
          person = new STRUCT (personDesc, conn, personAttrs);
     
          // Bind the Person_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a Person_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Create and insert a Student_t object into the database
        {
          // Obtain the Student_t type descriptor
          StructDescriptor studentDesc = 
            StructDescriptor.createDescriptor ("SCOTT.STUDENT_T", conn);
     
          // Prepare the Student_t attributes
          Datum[] studentAttrs = 
          {
            new NUMBER (1002), 
            new CHAR ("Peter", null), 
            new CHAR ("NY", null),
            new NUMBER (100), 
            new CHAR ("EE", null)
          };
     
          // Create a Student_t object
          person = new STRUCT (studentDesc, conn, studentAttrs);
     
          // Bind the Student_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a Student_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Create and insert a ParttimeStudent_t object into the database
        {
          // Obtain the ParttimeStudent_t type descriptor
          StructDescriptor parttimestudentDesc = 
            StructDescriptor.createDescriptor ("SCOTT.PARTTIMESTUDENT_T", conn);
     
          // Prepare the ParttimeStudent_t attributes
          Datum[] parttimestudentAttrs = 
          {
            new NUMBER (1003), 
            new CHAR ("John", null), 
            new CHAR ("LA", null),
            new NUMBER (101), 
            new CHAR ("CS", null), 
            new NUMBER (20)
          };
     
          // Create ParttimeStudent_t object
          person = new STRUCT (parttimestudentDesc, conn, parttimestudentAttrs);
     
          // Bind the ParttimeStudent_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion and print the update count
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a ParttimeStudent_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Create and insert a Employee_t object into the database
        {
          // Obtain the Employee_t type descriptor
          StructDescriptor employeeDesc = 
            StructDescriptor.createDescriptor ("SCOTT.EMPLOYEE_T", conn);
     
          // Prepare the Employee_t attributes
          Datum[] employeeAttrs = 
          {
            new NUMBER (1004), 
            new CHAR ("David", null),
            new CHAR ("SF", null), 
            new NUMBER (1111), 
            new CHAR ("SCOTT", null) 
          };
     
          // Create a Employee_t object
          person = new STRUCT (employeeDesc, conn, employeeAttrs);
     
          // Bind the Employee_t object
          pstmt.setObject (1, person, OracleTypes.STRUCT);
     
          // Execute the insertion
          if (pstmt.executeUpdate () == 1)
            System.out.println ("Successfully inserted a Employee_t object");
          else
            System.out.println ("Insertion failed");
        }
     
        // Close the PreparedStatment
        pstmt.close ();
      }
     
      /**
       * This method queries the database PersonTab table and print the
       * object table values.
       */
      public static void select (Connection conn) throws SQLException
      {
        System.out.println ("List the Person_t objects : ");
     
        // Create a statement
        Statement stmt = conn.createStatement ();
     
        // Execute the query
        ResultSet rset = stmt.executeQuery ("select value(t) from PersonTab t");
     
        // Iterate the result set
        while (rset.next ())
        {
          // The object value can be a Person_t, Student_t, ParttimeStudent_t
          // or Employee_t.
          STRUCT person = (STRUCT) rset.getObject (1);
     
          // Obtain the type descriptor 
          StructDescriptor desc = person.getDescriptor ();
     
          // Obtain the type metadata to display the attribute names
          ResultSetMetaData md = desc.getMetaData ();
     
          // Create a StringBuffer to save the attribute information
          StringBuffer sbuf = new StringBuffer ();
     
          // Write the SQL type name to hte StringBuffer
          sbuf.append (person.getSQLTypeName()+": ");
     
          // Access the Person_t attributes
          Datum[] attrs = person.getOracleAttributes ();
     
          // Iterate the attributes
          for (int i=0; i<attrs.length; i++)
          {      
            // For each attribute, we first write the attribute name 
            // the string buffer
            sbuf.append (md.getColumnName(i+1)+"=");
     
            // Write the attribute value to the string buffer
            sbuf.append (attrs[i].stringValue()+" ");
          }
          // Print the stringBuffer value
          System.out.println (sbuf.toString());
        }
     
        // Close the result set
        rset.close ();
     
        // Close the statement
        stmt.close ();
      }
    }

    yo merci mais c'est exactement ce que je fais
    en fait même en me loggant avec mon utilisateur admin j'ai la même erreur !

  4. #4
    Expert éminent sénior
    Avatar de SheikYerbouti
    Profil pro
    Inscrit en
    Mai 2003
    Messages
    6 760
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Mai 2003
    Messages : 6 760
    Points : 11 862
    Points
    11 862
    Par défaut
    Vous importez les mêmes classes ?
    Rédacteur Oracle (Oracle ACE)
    Guide Oracle ,Guide PL/SQL, Guide Forms 9i/10g, Index de recherche
    Je ne réponds pas aux questions techniques par MP
    Blogs: Forms-PL/SQL-J2EE - Forms Java Beans

  5. #5
    Membre à l'essai
    Inscrit en
    Septembre 2005
    Messages
    36
    Détails du profil
    Informations forums :
    Inscription : Septembre 2005
    Messages : 36
    Points : 19
    Points
    19
    Par défaut
    Citation Envoyé par SheikYerbouti
    Vous importez les mêmes classes ?
    ahah c'est un bug oracle on ne peut pas mettre de timestamp dans les types objet jusqu'a la version 10.1.2

    et pour les imports merci pour le "tuyau" car dans le tutorial tout est importé par package....

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 15
    Dernier message: 18/11/2008, 17h41
  2. emploi d'un sub select dans une procédure - Oracle 8i -
    Par mike devimo dans le forum Oracle
    Réponses: 2
    Dernier message: 29/03/2006, 17h18
  3. [forms6i] appel d'une procédure oracle en arrière plan
    Par ahlemahlem dans le forum Oracle
    Réponses: 3
    Dernier message: 09/02/2006, 20h19
  4. [JSP][STRUTS] Passer des objets à une classe action
    Par maphi dans le forum Servlets/JSP
    Réponses: 2
    Dernier message: 10/08/2005, 16h55
  5. Passer un tableau à une procédure stockée
    Par biroule dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 10/09/2004, 18h21

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