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.

Results 1 to 2 of 2

Thread: registration with access as DB

  1. #1
    Junior Member
    Join Date
    May 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default registration with access as DB

    hi ,

    I have created registration code with access as db, but table is not creating at access, i have already created DSN , but still it is not helpful.

    below is registration code

    import java.awt.*;
    import javax.swing.JFormattedTextField;
    import javax.swing.JFrame;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.Dialog;
    import java.awt.Frame;

    public class Registration implements ActionListener

    {
    Frame f; Label l1, l2, l3, l4; TextField f1,f2,f3,f4; Button b1,b2, b3; DBConnect d; Dialog d1;



    Registration ()

    {

    f= new Frame ("Registration");

    /* f.setLayout(null); */ // adding setBounds for sequential fields

    l1= new Label ("Email/Username");
    f1= new TextField (15);
    l2= new Label ("Full Name");
    f2= new TextField (25);
    l3= new Label ("Password");
    f3= new TextField (15);
    l4= new Label ("Address");
    f4= new TextField (50);
    f3.setEchoChar('?');
    d=new DBConnect();
    //d1=new Dialog();








    //f3.setEchoChar ("*");

    b1 = new Button ("Register Me");
    b2 = new Button ("Cancel");
    b3 = new Button ("test");
    f.setLayout (null);

    l1.setBounds(10,70,100,30);
    f1.setBounds(120,70,180,40);
    l2.setBounds(10,130,100,30);
    f2.setBounds(120,130,180,40);
    l3.setBounds(10,190,100,30);
    f3.setBounds(120,190,180,40);
    l4.setBounds(10,250,100,30);
    f4.setBounds(120,250,180,40);
    b1.setBounds(10,330,150,30);
    b2.setBounds(180,330,150,30);
    b3.setBounds(20,330,30,30);




    f.add (l1);
    f.add (f1);
    f.add (l2);
    f.add (f2);
    f.add (l3);
    f.add (f3);
    f.add (l4);
    f.add (f4);
    f.add (b1);
    f.add (b2);
    //f.add (d);
    b1.addActionListener(this);
    b2.addActionListener(this);
    f.setSize (800,800);
    f.setVisible(true);


    //f.setDefaultCloseOperation(WindowConstants.DO_NOTH ING_ON_CLOSE);
    f.addWindowListener(new WindowAdapter() { //code for closing window
    public void windowClosing(WindowEvent ev) {
    boolean close = true;
    // check some files, asking if the user wants to save
    // YES and NO handle OK, but if the user hits Cancel on any file,
    // I want to abort the close process
    // So if any of them hit Cancel, I set "close" to false
    if (close) {
    f.dispose();
    System.exit(0);
    }
    }
    });



    }

    public void actionPerformed(ActionEvent e)
    {
    String x1 = f1.getText();
    String x2 = f2.getText();
    String x3 = f3.getText();
    String x4 = f4.getText();
    d=new DBConnect();


    if (e.getSource()==f1)
    {if (x1.equals(""))
    {
    d1.setVisible(true);
    }

    }
    else

    {
    d.s.execute( "insert into yogi values ('"+x1+"','"+x2+"', '"+x3+"','"+x4+"')");

    }
    }
    public static void main(String[] args)
    {
    Registration r= new Registration ();
    }
    }






    below is table create code

    class TableCreate
    {
    DBConnect d;



    TableCreate()
    {

    try
    {
    d=new DBConnect();
    d.s.execute("Create table Register (Email/Username text(20) Full Name text(10),Password text (50), Address text (50))");

    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }

    public static void main(String[] args)
    {
    System.out.println("DB Created");
    }

    }



    below is DB create code


    import java.sql.*;


    public class DBConnect
    {
    Connection c;
    Statement s;

    public DBConnect()
    {
    try
    {
    DriverManager.registerDriver (new sun.jdbc.odbc.JdbcOdbcDriver());
    c=DriverManager.getConnection("jdbcdbc:yogi");
    s=c.createStatement();

    }
    catch(Exception e)
    {
    e.printStackTrace();
    }

    }
    public static void main(String[] args)
    {
    System.out.println("connected");
    }


    }



    Awaiting revert


    Thanks,
    Yogendra


  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    Posts
    2,642
    My Mood
    Daring
    Thanks
    90
    Thanked 263 Times in 232 Posts

    Default Re: registration with access as DB

    Quote Originally Posted by ylo007 View Post
    ...but table is not creating at access,...
    Add some printlns to see where the program does not perform as expected.
    Please edit your post and wrap your code in code tags to make it easier for everyone to read.

Similar Threads

  1. Membership registration system and email reminder to members
    By JavaClicks in forum Java Theory & Questions
    Replies: 0
    Last Post: July 16th, 2012, 09:18 AM
  2. How to do MD5 encryption in JSP for password login and registration?
    By sadaharu in forum JavaServer Pages: JSP & JSTL
    Replies: 4
    Last Post: June 21st, 2012, 11:58 AM
  3. How to write registration module
    By speedzojie in forum Java Theory & Questions
    Replies: 3
    Last Post: May 10th, 2010, 03:03 AM
  4. Default Access (package access) confusion
    By gauravrajbehl in forum Java Theory & Questions
    Replies: 1
    Last Post: November 18th, 2009, 04:11 AM