Results 1 to 3 of 3
  1. #1
    Adeelnawaz is offline Member
    Join Date
    Nov 2012
    Posts
    1
    Rep Power
    0

    Default to display table data from jdbc

    here is code

    import java.io.*;
    import javax.swing.*;
    package student;
    import java.sql.*;

    public class Main {
    private static Object driverManager;

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    try{
    load driverClass.forName("sun.jdbc.odbc.JdbcOdbcDriver" );
    String url = "jdbc:odbc:studentDSN";
    Connection con = driverManager.getConnection(url);
    Statement st = con.createStatement();
    String sql = "SELECT * FROM Student";
    ResultSet rs = st.executeQuery(sql);
    while(rs.next())
    {
    String name = rs.getString(“name”);String add = rs.getString(“address”);
    String pNum = rs.getString(“phoneNum”);
    System.out.println(name + “ ” + add + ” ” + pNum);
    con.close();
    }
    catch(Exception sqlEx)
    {
    System.out.println(sqlEx);
    }
    }

    private static void forName(String string) {
    throw new UnsupportedOperationException("Not yet implemented");
    }
    // TODO code application logic here
    }

    }


    pls tell how i can correct mistake

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

    Default Re: to display table data from jdbc

    Moved from Suggestions & Feedback.

    Please go through Guide For New Members and BB Code List - Java Programming Forum and edit your post accordingly.

    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
    11,450
    Rep Power
    18

    Default Re: to display table data from jdbc

    And when you've sorted out the format (that is, added [code] tags [/code] to your code so it's easier to read), you might want to actually say what mistake you've made.
    Please do not ask for code as refusal often offends.

Similar Threads

  1. How to display data against row clicked on html table?
    By reubenmk in forum Java Servlet
    Replies: 3
    Last Post: 02-23-2012, 02:20 PM
  2. how to display data in a table format using jstl tag
    By anand12356 in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 02-09-2011, 01:26 PM
  3. Table display
    By gissah in forum NetBeans
    Replies: 1
    Last Post: 06-25-2009, 08:20 AM
  4. how to display the alerts in table
    By geeta_ravikanti in forum JDBC
    Replies: 4
    Last Post: 04-04-2008, 06:45 AM
  5. Data formatting for the <display:table>
    By yuchuang in forum Web Frameworks
    Replies: 3
    Last Post: 12-14-2007, 10:52 AM

Tags for this Thread

Posting Permissions

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