Results 1 to 5 of 5
  1. #1
    sysout is offline Member
    Join Date
    Aug 2009
    Posts
    66
    Rep Power
    0

    Default Constructor Error ?

    Java Code:
    Connection conn;
            Statement stmt;
            ResultSet rs;
            Connect A = new Connect();
            conn = (Connection) A.getConnection();
            try {
                stmt = (Statement) conn.createStatement();
                rs = stmt.executeQuery("SELECT * FROM MsJenisBarang WHERE kdJenisBarang = 3");
                lblKode.setText(rs.getString(1));
            } catch (SQLException ex) {
                Logger.getLogger(EditJenisBarang.class.getName()).log(Level.SEVERE, null, ex);
            }
    I put this code to Constructor.
    No error, but The lblKode doesn't display any value..
    lblKode.setText(rs.getString(1));
    if I replace that code to lblKode.setText("12345"); -> it works.

    ?? confused -__-"

  2. #2
    mrmatt1111's Avatar
    mrmatt1111 is offline Senior Member
    Join Date
    Aug 2009
    Location
    San Jose, CA, USA
    Posts
    320
    Rep Power
    6

    Default

    try this:

    Java Code:
    if(rs.next())
    {
       lblKode.setText(rs.getString(1));
    }
    My Hobby Project: LegacyClone

  3. #3
    sysout is offline Member
    Join Date
    Aug 2009
    Posts
    66
    Rep Power
    0

    Default

    yeahhh..thanks bro.. solved

  4. #4
    sysout is offline Member
    Join Date
    Aug 2009
    Posts
    66
    Rep Power
    0

    Default

    emm..any problems again..

    JFrame 1 (JenisBarang.java) :
    Java Code:
    public int getKdJenisBarang() {
            return kdJenisBarang;
        }
    
        public void setKdJenisBarang(int kdJenisBarang) {
            this.kdJenisBarang = kdJenisBarang;
        }
        this.setKdJenisBarang(5); //set the value

    JFrame2 (EditJenisBarang.java) :
    Java Code:
            JenisBarang jb = new JenisBarang();
            int KdJenisBarang = jb.getKdJenisBarang();
    it doesn't get any results for passing parameter from one frame to another.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    It may be difficult to determine what is not working based on the code and information that you have given us. You may wish to post a small compilable program that demonstrates your problem plus give a little more information. Detail is important here.

Similar Threads

  1. Replies: 9
    Last Post: 10-18-2008, 08:26 PM
  2. why do I got this error about the constructor ?
    By aneuryzma in forum New To Java
    Replies: 4
    Last Post: 08-14-2008, 10:22 PM
  3. "Cannont find symbol Constructor" error
    By Welsh in forum New To Java
    Replies: 7
    Last Post: 01-25-2008, 12:12 AM
  4. Replies: 0
    Last Post: 12-19-2007, 09:10 AM
  5. Error: cannot find symbol constructor
    By zoe in forum New To Java
    Replies: 1
    Last Post: 07-24-2007, 08:24 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
  •