Results 1 to 9 of 9
Thread: swing coding
- 01-09-2009, 09:02 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 3
- Rep Power
- 0
swing coding
hiiiii
actualy i wanna retrive data from MS Acsess in java swing
but i have an error
so u plz help me in solving dat error.....thanx
this is my code
there is two programs one for database and second one is for where data is shown in table.
.................................................. .................................................. ....
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Logger extends JFrame implements ActionListener
{
JButton jb1,jb2;
JLabel jl1,jl2,jl3;
JTextField jtf;
JPasswordField jp;
String x;
String y;
public Logger()
{
jl1=new JLabel("<html><center><font face=Maiandra GD size=5><u>Welcome to</u><p>School Management System</font></html>");
Container cont=getContentPane();
jl2=new JLabel("Enter Name");
jl3=new JLabel("Enter Password");
JPanel jpp=new JPanel();
jpp.setLayout(null);
jtf=new JTextField(10);
jp=new JPasswordField(10);
jpp.add(jl1);
jpp.add(jl2);
jpp.add(jl3);
jpp.add(jtf);
jpp.add(jp);
jb1=new JButton("Save");
jb1.addActionListener(this);
jpp.add(jb1);
jl1.setBounds(80,5,300,80);
jl2.setBounds(100,75,120,10);
jl3.setBounds(100,78,300,80);
jtf.setBounds(205,75,120,20);
jp.setBounds(205,105,120,20);
jb1.setBounds(205,135,70,29);
cont.add(jpp);
setTitle("Log In");
setSize(500,200);
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
x=jtf.getText();
y=jp.getText();
JDta jxy=new JDta();
jxy.putting(x,y);
dispose();
new Salary();
}
public static void main(String aa[])
{
new Logger();
}
}
.................................................. .................................................. ....
import java.sql.*;
public class JDta
{
public void putting(String x,String y)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:stu","" ,"");
PreparedStatement stmt=con.prepareStatement("insert into data values(?,?)");
stmt.setString(1,x);
stmt.setString(2,y);
stmt.executeUpdate();
stmt.close();
con.close();
}
catch(Exception er)
{
}
}
public boolean checking(String x,String y)
{
int coun=0;
boolean bb;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:exams", "","");
PreparedStatement stmt=con.prepareStatement("select * from data where name=? and pass=?");
stmt.setString(1,x);
stmt.setString(2,y);
ResultSet rs=stmt.executeQuery();
while(rs.next())
{
coun++;
}
stmt.close();
con.close();
}
catch(Exception er)
{
}
if(coun>0)
bb=true;
else
bb=false;
return bb;
}
}
- 01-09-2009, 10:01 AM #2
Senior Member
- Join Date
- Nov 2008
- Posts
- 286
- Rep Power
- 5
If you want help, can I suggest:
- don't just post a big slab of poorly formatted code and say "I have a problem"
- instead, describe precisely what problem you're having, and try and hone it down to a few lines.Neil Coffey
Javamex - Java tutorials and performance info
- 01-09-2009, 10:02 AM #3
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
new Salary(); call for?
- 01-10-2009, 07:26 AM #4
Member
- Join Date
- Jan 2009
- Posts
- 3
- Rep Power
- 0
thanx for replying
:)swing coding
hiiiii
thanx for replying
but that was not solution of problem
ok if you remove new salary(); then still the data from database is nt showing.
actualy i wanna retrive data from MS Acsess in java swing
but i have an error
so u plz help me in solving dat error.....thanx
this is my code
there is two programs one for database and second one is for where data is shown in table.
.................................................. .................................................. ....
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class Logger extends JFrame implements ActionListener
{
JButton jb1,jb2;
JLabel jl1,jl2,jl3;
JTextField jtf;
JPasswordField jp;
String x;
String y;
public Logger()
{
jl1=new JLabel("<html><center><font face=Maiandra GD size=5><u>Welcome to</u><p>School Management System</font></html>");
Container cont=getContentPane();
jl2=new JLabel("Enter Name");
jl3=new JLabel("Enter Password");
JPanel jpp=new JPanel();
jpp.setLayout(null);
jtf=new JTextField(10);
jp=new JPasswordField(10);
jpp.add(jl1);
jpp.add(jl2);
jpp.add(jl3);
jpp.add(jtf);
jpp.add(jp);
jb1=new JButton("Save");
jb1.addActionListener(this);
jpp.add(jb1);
jl1.setBounds(80,5,300,80);
jl2.setBounds(100,75,120,10);
jl3.setBounds(100,78,300,80);
jtf.setBounds(205,75,120,20);
jp.setBounds(205,105,120,20);
jb1.setBounds(205,135,70,29);
cont.add(jpp);
setTitle("Log In");
setSize(500,200);
setVisible(true);
}
public void actionPerformed(ActionEvent ae)
{
x=jtf.getText();
y=jp.getText();
JDta jxy=new JDta();
jxy.putting(x,y);
dispose();
}
public static void main(String aa[])
{
new Logger();
}
}
.................................................. .................................................. ....
import java.sql.*;
public class JDta
{
public void putting(String x,String y)
{
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbc:stu","" ,"");
PreparedStatement stmt=con.prepareStatement("insert into data values(?,?)");
stmt.setString(1,x);
stmt.setString(2,y);
stmt.executeUpdate();
stmt.close();
con.close();
}
catch(Exception er)
{
}
}
public boolean checking(String x,String y)
{
int coun=0;
boolean bb;
try
{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbcdbc:exams", "","");
PreparedStatement stmt=con.prepareStatement("select * from data where name=? and pass=?");
stmt.setString(1,x);
stmt.setString(2,y);
ResultSet rs=stmt.executeQuery();
while(rs.next())
{
coun++;
}
stmt.close();
con.close();
}
catch(Exception er)
{
}
if(coun>0)
bb=true;
else
bb=false;
return bb;
}
}
- 01-12-2009, 09:38 AM #5
Senior Member
- Join Date
- Dec 2008
- Location
- Hong Kong
- Posts
- 473
- Rep Power
- 5
so, what are the error msgs are?
- 01-12-2009, 09:53 AM #6
Senior Member
- Join Date
- Dec 2008
- Location
- Kolkata
- Posts
- 280
- Rep Power
- 5
The : is probably missing in your code
Connection con=DriverManager.getConnection("jdbc: odbc:exams", "","");
There wont be any space between : and o , just for formatting issues of the forum I included a space.
- 01-28-2009, 09:26 AM #7
Member
- Join Date
- Jan 2009
- Posts
- 3
- Rep Power
- 0
hiiiiiiii
i have a question dat
if we use our swing code of different class and copy it in any netbens 6.5project,then in net beans 6.5 why in dat option for Design View is not shows...
plz reply as soon as possible......
thank you
-
A great resource that has helped me and will probably help you is an article entitled How To Ask Questions The Smart Way. It will tell you how to formulate your questions so that the folks here will be better able to answer them. Good luck.
- 01-30-2009, 07:18 AM #9
Similar Threads
-
coding help
By accies76 in forum New To JavaReplies: 5Last Post: 11-12-2008, 08:15 PM -
Coding Java on a Mac
By Menre in forum New To JavaReplies: 5Last Post: 05-06-2008, 05:49 AM -
Need Help Coding Project
By Bascotie in forum New To JavaReplies: 9Last Post: 04-27-2008, 11:31 PM -
Problem in my coding
By one198 in forum New To JavaReplies: 9Last Post: 08-09-2007, 10:07 AM -
Help with program coding
By cachi in forum AWT / SwingReplies: 1Last Post: 07-31-2007, 07:16 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks