Please, create a program that contains a JFrame and a Database, using the follow
ID: 3728032 • Letter: P
Question
Explanation / Answer
public class MusicLibriary
{
private long upc,
private String albumname;
private String artistname;
private String imagename;
private String genere;
private String date;
private int rank;
private Double price;
private String format;
}
public class Design extends JFrame implements ActionListener
{
login.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//get the username and password from the text filelds
//Get the netred user name and passord
String sLogin = login.getText();
String sPass = pass.getText();
//make a JDBC call to data base and validate the username and password
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); // corresponding oracle or sql driver
String url=null,url1=null,
String sql=null;
dbFileName = "C:/db.accdb";
url = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb, *.accdb)};"+
"DBQ="+dbFileName+";"; // url of your respective database
con=DriverManager.getConnection(url);
st=con.createStatement();
ResultSet rs=st.executeQuery("select password from LOGIN1 where uname='"+sLogin.trim()+"'");
if(rs.next()){
if(rs.getString(1).equals(sPass)){
//sho the menu
JMenuBar menuBar;
JMenu menu, submenu;
JMenuItem menuItem;
JRadioButtonMenuItem rbMenuItem;
JCheckBoxMenuItem cbMenuItem;
//Create the menu bar.
menuBar = new JMenuBar();
//Build the first menu.
menu = new JMenu("A Menu");
menu.setMnemonic(KeyEvent.VK_A);
menu.getAccessibleContext().setAccessibleDescription(
"The only menu in this program that has menu items"); // desciption of items
menuBar.add(menu); // add all the menu itmes that are needed.
}else{
JOptionPane.showMessageDialog(this,"Invalid Password");
}
}
});
}