Results 1 to 3 of 3

Thread: Database

  1. #1
    tech is offline Member
    Join Date
    Jul 2010
    Posts
    1
    Rep Power
    0

    Default Database

    Hi I have created a class as below

    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.logging.Level;

    import java.util.logging.Logger;


    public class NewClass1 {
    {

    try {
    Class.forName("sun.odbc.JdbcOdbcDriver");
    Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/ant", "root", "")
    try {
    Statement st = con.createStatement();
    ResultSet rs = st.executeQuery("SELECT*FROM SF");
    String jTextField1 = rs.getString("");



    } catch (SQLException ex) {
    Logger.getLogger(NewClass1.class.getName()).log(Le vel.SEVERE, null, ex);
    }
    } catch (SQLException ex) {
    Logger.getLogger(NewClass1.class.getName()).log(Le vel.SEVERE, null, ex);
    } catch (ClassNotFoundException ex) {
    Logger.getLogger(NewClass1.class.getName()).log(Le vel.SEVERE, null, ex);
    }

    }



    }





    And created a form with a jTextField, a jbutton and a jtable. The scope is that when I type a name in the textfieldand press the button, the rest of the information that matches the data in the field will populate the table. I the data is stored in a database.

    I don't know how to continue from here, any help please.
    Last edited by tech; 07-25-2010 at 05:40 PM.

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,335
    Blog Entries
    7
    Rep Power
    20

    Default

    I don't see a JTable anywhere, nor any other component. All I see is this:

    Java Code:
    String jTextField1 = rs.getString("");
    Do you really have a database column labeled ""? First check if you can fetch your data from your database.

    kind regards,

    Jos

  3. #3
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,305
    Rep Power
    25

    Default

    You need to work on the GUI part of your program. Use the JFrame class and then add the components to it that you need.
    Read the Tutorial at The Java™ Tutorials about how to write GUI.
    Also use Search on this forum for many samples of code for GUI.

Similar Threads

  1. xml to database from xml rpc
    By kievari in forum JDBC
    Replies: 1
    Last Post: 12-11-2009, 12:14 AM
  2. database
    By kswiss in forum AWT / Swing
    Replies: 0
    Last Post: 03-26-2009, 11:51 AM
  3. help with database
    By fahien_akim in forum NetBeans
    Replies: 0
    Last Post: 03-07-2009, 01:44 PM
  4. Replies: 2
    Last Post: 02-11-2009, 04:43 AM
  5. Database in a PDA
    By percivalwcy in forum JDBC
    Replies: 2
    Last Post: 08-08-2007, 03:10 AM

Posting Permissions

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