-
Database Help
Hi.Don't know if anyone can help me but I have a project involving databases.My problem is I'm trying to create buttons that will allow the user to delete,insert and update data into the various fields in the database.They have to be able to see the rows during and after editing.
-
This could possibly be solved by a mix of database code and a Swing GUI cpde (if a desk-top app), but I think that you'll need to provide a lot more detail here on just what your requirements are and what you've got so far.
-
Database help
thanks a l ot for replying so soon. My project is sort of a DVD rental application that will allow users to rent or purchase movies. I have seperate screens one for the users and one for an administrator.All the administrator does is udate,delete,add new movies from databases that I have created.
Heres most of the code
[code]
-
Database help
thanks a l ot for replying so soon. My project is sort of a DVD rental application that will allow users to rent or purchase movies. I have seperate screens one for the users and one for an administrator.All the administrator does is udate,delete,add new movies from databases that I have created.
Heres most of the code.Im using netbeans 6.5 so I will omit some generated code,Frames,buttons etc.
Login Screen
Code:
package supadvd;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class MainMenu extends javax.swing.JFrame {
public MainMenu() {
initComponents();
}
String ID[] = new String[999];
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
int row = 0;
String password = jPasswordField1.getText();
Connection conn = null;
try {
// Step 1: Load the JDBC driver.
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
// Step 2: Establish the connection to the database.
// String url = "jdbc:odbc:contact_mgr";
String url = "jdbc:odbc:;Driver={Microsoft Access Driver (*.mdb)};Dbq=C:\\movies.mdb";
conn = DriverManager.getConnection(url,"user1","password");
} catch (Exception e)
jLabel9.setText("CONNECTION FAILED");
System.err.println("Got an exception! ");
System.err.println(e.getMessage());
}
try
{
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery("SELECT * FROM Client");
for(int j = 0;j < 50;j++)
{
while (rs.next())
{
ID[row] = rs.getString("StudentId");
if(password.equalsIgnoreCase(ID[row]))
{
ClientSelection next;
next = new ClientSelection ();
next.setVisible(true);
this.hide();
}
else
if(password.equals("oldboys"))
{
Administrator follow;
follow = new Administrator ();
follow.setVisible(true);
this.hide();
}
else
{
jLabel9.setText("Wrong Password");
}
}
stmt.close();
conn.close();
}
}catch(Exception e) {
System.err.println();
}
Now my problem is I want the administrator to be able to delete,update,insert new data into the database from my program I dont know if you can help me.I would really appreciate it if you could though.