urgently need help

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2009
Posts: 1
Reputation: priya_gurnani is an unknown quantity at this point 
Solved Threads: 0
priya_gurnani priya_gurnani is offline Offline
Newbie Poster

urgently need help

 
0
  #1
Jan 16th, 2009
actualy i need help
i m making a software in java swing
i hv a problem in retriving values from database in JTable,
i m inserting values in database ms access it works,
following is my code one is for database another one for table
.....................................................................................................................................
  1. import java.sql.*;
  2. public class JDta
  3. {
  4. public void putting(String x,String y)
  5. {
  6. try
  7. {
  8. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  9. Connection con=DriverManager.getConnection("jdbc:odbc:pproject","","");
  10. PreparedStatement stmt=con.prepareStatement("insert into data values(?,?)");
  11. stmt.setString(1,x);
  12. stmt.setString(2,y);
  13. stmt.executeUpdate();
  14. stmt.close();
  15. con.close();
  16. }
  17. catch(Exception er)
  18. {
  19. }
  20. }
  21.  
  22. public boolean checking(String x,String y)
  23. {
  24. int coun=0;
  25. boolean bb;
  26. try
  27. {
  28. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  29. Connection con=DriverManager.getConnection("jdbc:odbc:exams","","");
  30. PreparedStatement stmt=con.prepareStatement("select * from data where name=? and pass=?");
  31. stmt.setString(1,x);
  32. stmt.setString(2,y);
  33. ResultSet rs=stmt.executeQuery();
  34. while(rs.next())
  35. {
  36. coun++;
  37. }
  38. stmt.close();
  39. con.close();
  40. }
  41. catch(Exception er)
  42. {
  43. }
  44. if(coun>0)
  45. bb=true;
  46. else
  47. bb=false;
  48. return bb;
  49. }
  50. }
  51. ......................................................................................................................................
  52. import javax.swing.*;
  53. import java.awt.*;
  54. import java.awt.event.*;
  55. class Logger extends JFrame implements ActionListener
  56. {
  57. JButton jb1,jb2;
  58. JLabel jl1,jl2,jl3;
  59. JTextField jtf;
  60. JPasswordField jp;
  61. String x;
  62. String y;
  63. public Logger()
  64. {
  65. jl1=new JLabel("<html><center><font face=Maiandra GD size=5><u>Welcome to</u><p>School Management System</font></html>");
  66. Container cont=getContentPane();
  67. jl2=new JLabel("Enter Name");
  68. jl3=new JLabel("Enter Password");
  69. JPanel jpp=new JPanel();
  70. jpp.setLayout(null);
  71. jtf=new JTextField(10);
  72. jp=new JPasswordField(10);
  73. jpp.add(jl1);
  74. jpp.add(jl2);
  75. jpp.add(jl3);
  76. jpp.add(jtf);
  77. jpp.add(jp);
  78. jb1=new JButton("Save");
  79. jb1.addActionListener(this);
  80. jpp.add(jb1);
  81. jl1.setBounds(80,5,300,80);
  82. jl2.setBounds(100,75,120,10);
  83. jl3.setBounds(100,78,300,80);
  84. jtf.setBounds(205,75,120,20);
  85. jp.setBounds(205,105,120,20);
  86. jb1.setBounds(205,135,70,29);
  87. cont.add(jpp);
  88. setTitle("Log In");
  89. setSize(500,200);
  90. setVisible(true);
  91. }
  92. public void actionPerformed(ActionEvent ae)
  93. {
  94. x=jtf.getText();
  95. y=jp.getText();
  96. JDta jxy=new JDta();
  97. jxy.putting(x,y);
  98. dispose();
  99.  
  100. }
  101. public static void main(String aa[])
  102. {
  103. new Logger();
  104. }
  105. }
......................................................................................................................................
Last edited by ~s.o.s~; Jan 16th, 2009 at 3:51 am. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Jul 2007
Posts: 1,175
Reputation: stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light stephen84s is a glorious beacon of light 
Solved Threads: 125
Featured Poster
stephen84s's Avatar
stephen84s stephen84s is offline Offline
Veteran Poster

Re: urgently need help

 
0
  #2
Jan 16th, 2009
Would you mind helping us help you by helping yourself to this announcement at the top of the forum regarding the use of code tags and Oh Yes !!! in the mean time also describe what is actually going wrong.
Last edited by stephen84s; Jan 16th, 2009 at 3:49 am.
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand."

"How to ask questions the smart way ?"
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 1,677
Reputation: javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all javaAddict is a name known to all 
Solved Threads: 226
Featured Poster
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Posting Virtuoso

Re: urgently need help

 
0
  #3
Jan 16th, 2009
And what are you trying to accomplish by doing this:

  1. jl1=new JLabel("<html><center><font face=Maiandra GD size=5><u>Welcome to</u><p>School Management System</font></html>");
Check out my New Bike at my Public Profile at the "About Me" tab
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC