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