So here am I trying to work with my assignment. I think I'm doing it right but when I open my userlogin.accdb my tables didn't update. I don't know what to do anymore, I tried everything but unfortunately it didn't work.
here's my code. I Hope you can help me guys.
importjavax.swing.*;importjava.awt.*;importjava.awt.event.*;importjava.sql.*;publicclassSignUpextendsJFrameimplementsActionListener{finalintwidth=400;finalintheight=200;JLabeluserr=newJLabel("UserName");JLabelpasss=newJLabel("Password");JTextFieldusernamee=newJTextField(10);JPasswordFieldpasswordd=newJPasswordField(10);JButtonconfirm=newJButton("Confirm");Stringuser=usernamee.getText();charpass[]=passwordd.getPassword();publicSignUp(){super("SIGNUP");setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);setSize(width,height);setLayout(newFlowLayout());add(userr);add(usernamee);add(passs);add(passwordd);add(confirm);confirm.addActionListener(this);}publicvoidactionPerformed(ActionEventa){Stringurl="jdbc:odbc:JavaCourse";Stringquery="SELECT UserName,Password FROM userlogin";try{Connectioncon=DriverManager.getConnection("jdbc:ucanaccess://C:\\Users\\Jeybee\\Desktop\\UserLogIn.accdb");Statementstmt=con.createStatement();ResultSetrs=stmt.executeQuery(query);stmt.executeUpdate("INSERT INTO userlogin "+"(Username,Password)"+"VALUES ('"+user+"' + , ' "+pass+"')");}catch(SQLExceptionex){while(ex!=null){System.out.println("SQL Exception: "+ex.getMessage());ex=ex.getNextException();}}}publicstaticvoidmain(String[]args){SignUpsign=newSignUp();sign.setVisible(true);}}
Last edit: Gord Thompson 2016-02-28
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
So here am I trying to work with my assignment. I think I'm doing it right but when I open my userlogin.accdb my tables didn't update. I don't know what to do anymore, I tried everything but unfortunately it didn't work.
here's my code. I Hope you can help me guys.
Last edit: Gord Thompson 2016-02-28
I'm not sure about NetBeans, but Eclipse won't even compile your code. For one thing, your connection URL is invalid:
is malformed because of the bare backslashes in the file path
try using forward slashes instead: