Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

1 Visitor Messages

  1. hello there im making a jdbc program now,...the mysql and netbeans connection is okay since some part of my progrm is ok now....my only problem is my Jtable dont display my MYSQL database table values....here's the code:

    Class.forName("com.mysql.jdbc.Driver").newInstance ();
        Connection con1 = (Connection) DriverManager.getConnection("jdbc:mysql://localhost:3306/myDB", "root", "");
        Statement st1 = (Statement) con1.createStatement();
        ResultSet rs1 = st1.executeQuery("SELECT * FROM stocks");
        ResultSetMetaData md = (ResultSetMetaData) rs1.getMetaData();
        int columnCount = md.getColumnCount();
        Vector columns = new Vector(columnCount);
     
        for(int i=1; i<=columnCount; i++)
        columns.add(md.getColumnName(i));
     
        Vector data = new Vector();
        Vector row
        while(rs1.next())
        {
        row = new Vector(columnCount);
        for(int i=1; i<=columnCount; i++)
        {
        row.add(rs1.getString(i));
        }
        data.add(row);
        }
     
        DefaultTableModel model = new DefaultTableModel(data, columns);
        jTable1 = new JTable(model);
     
        }catch(Exception e){
        e.printStackTrace();
        }
        }
Showing Visitor Messages 1 to 1 of 1
About dord_zen

Basic Information

About dord_zen
Java Skill Level:
Intermediate

Statistics


Total Posts
Total Posts
1
Posts Per Day
0.00
Visitor Messages
Total Messages
1
Most Recent Message
May 29th, 2012 12:52 PM
Total Thanks
Total Thanks
0
  • Thanked 0 Times in 0 Posts
General Information
Last Activity
June 2nd, 2012 01:54 AM
Join Date
May 29th, 2012