Professional Documents
Culture Documents
try
{
Class.forName("com.mysql.jdbc.Driver");
Connection con = (Connection)
DriverManager.getConnection("jdbc:mysql://localhost/susms","root","");
String qry ="select * from Students where ID='" +
txtSearch.getText() + "'" ;
Statement pst = (Statement) con.prepareStatement(qry);
ResultSet rs = pst.executeQuery(qry);
jTable1.setModel(net.proteanit.sql.DbUtils.resultSetToTableModel(rs));
}
catch (Exception e)
{
JOptionPane.showMessageDialog(this, e);
}
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javax.swing.JOptionPane;
Button Checking
try
Class.forName("com.mysql.jdbc.Driver");
ResultSet rs;
rs=std.executeQuery(slct);
if(rs.next())
txtsecQ.setText(rs.getString("SQ"));
}
else
catch (Exception e)
JOptionPane.showMessageDialog(null , e);
Button Forget
try
Class.forName("com.mysql.jdbc.Driver");
ResultSet rs;
rs=std.executeQuery(slct);
if(rs.next())
txtpass.setText(rs.getString("Password"));
else
{
txtsecA.setText("");
catch(Exception ex)
JOptionPane.showMessageDialog(null , ex);
try {
if(p==0)
{
Class.forName("com.mysql.jdbc.Driver");
String sql="select * from users where name='"+ txtname.getText() +"' and password='"+
txtoldpass.getText() +"'";
ResultSet rs;
rs=std.executeQuery(sql);
if(!rs.next())
txtnewpass.setText("");
txtname.setText("");
else
std.executeUpdate(updte);
catch(Exception ex)
JOptionPane.showMessageDialog(null,ex);