Results 1 to 7 of 7

Thread: Object message

  1. #1
    HMFouad is offline Member
    Join Date
    May 2012
    Location
    Algeria-Tiaret
    Posts
    12
    Rep Power
    0

    Default Object message

    Hello

    I am working with Netbeans and the JADE platform for the creation of agents and I have a database also

    So I want to know how I can send an object that contains ID "Integer" and this object is the result of a query that results in 0.1 or several ID

    That's a part from my code:

    Java Code:
    Object[] obj={"Id1 1","Id 2","Id 3","Id 4","Id 5","Id 6"} ;
                                            try{
                     Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        cnx = DriverManager.getConnection("jdbc:odbc:Produits_link");
                        St = cnx.createStatement();
                        ResultSet Rs;
                        i=0;
                        Rs=St.executeQuery("Select * From Liste_produits WHERE (Nom_produit=msg");
                        while (Rs.next()){
            i=i+1;
            Id = Rs.getInt("Id");
    //        obj=Id;
    			try {
    			
    			// Le contenu de réponse est l'objet <obj>
    			reply.setContentObject(obj);
    			
    			} catch (IOException e) {
    			
    				e.printStackTrace();
    			}
    Last edited by DarrylBurke; 06-11-2012 at 08:19 AM. Reason: Removed CENTER formatting

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,244
    Rep Power
    19

    Default Re: Object message

    I've removed the annoying CENTER formatting that you placed around your entire post, as it makes the text extremely difficult to follow. This is at least the third time I've done this for you. In future, if you post with crazy formatting, I'm going to ignore it, and almost all members here won't even try to read it.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  3. #3
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Object message

    So you're getting a list of ids from the database.
    So make a List<Integer> and use that?
    Not knowing what your actual requirements are I doubt anyone could say more than that.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  4. #4
    HMFouad is offline Member
    Join Date
    May 2012
    Location
    Algeria-Tiaret
    Posts
    12
    Rep Power
    0

    Default Re: Object message

    my database table contains a list of products, each product has an ID "Integer".

    I would sent a message that contains a list of ID and I did not know the nembre of these elements

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Object message

    So use a List<Integer> instead of Integer[].
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  6. #6
    HMFouad is offline Member
    Join Date
    May 2012
    Location
    Algeria-Tiaret
    Posts
    12
    Rep Power
    0

    Default Re: Object message

    Quote Originally Posted by Tolls View Post
    So use a List<Integer> instead of Integer[].
    Thank you but How can I use this type???

    Iam a beginer in Java

  7. #7
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,015
    Rep Power
    20

    Default Re: Object message

    Collections tutorial.
    That will give you a good overview of how the collections framework works.

    And I would question why a beginner who does not know about that framework is doing JDBC.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Replies: 1
    Last Post: 01-09-2012, 04:46 PM
  2. Replies: 1
    Last Post: 02-02-2011, 06:11 PM
  3. Replies: 2
    Last Post: 06-22-2010, 04:29 AM
  4. Replies: 6
    Last Post: 06-04-2010, 08:43 PM
  5. Replies: 1
    Last Post: 03-04-2009, 06:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •