Login codes using java database (validates with Microsoft Access File)

hi all pro-programmer, can you show me the code to login with the username and password using java database. When the user enters the username and password in the login page then it will go to the requested page. may i know how to do it?

no one will give you complete code.
i'll lay out the pieces for you, though:
(1) start with a User object. give it username and password attributes.
(2) write a UserDAO interface with CRUD operations for a User object.
(3) write a UserDAOImpl for your Microsoft Access database
(4) write an AuthenticationService interface
(5) write an implementation of the AuthenicationService that works with the UserDAO to authorize a User.
Use a servlet to accept request from your login page and pass it off to the service. Voila.
PS - Here's skeleton to start with. UI, servlet, and controller are your responsibility:
package model;
public class User implements Serializable
    private String username;
    private String password;
    public User(String u, String p)
        this.username = u;
        this.password = p;
    public String getUsername() { return username; }
    public String getPassword() { return password; }
public interface UserDAO
    public User findByUsername(String username);
    public void saveOrUpdate(User user);
    public void delete(User user);
public class UserDAOImpl implements UserDAO
    private Connection connection;
    public UserDAOImpl(Connection connection)
        this.connection = connection;
    public User findByUsername(String username)
        String password = "";
        // logic for querying the database for a User
        return new User(username, password);
    public void saveOrUpdate(User user)
        // save or update a User
    public void delete(User user)
        // delete a User
public interface AuthenticationService
    public boolean isAuthorized(String username);
public class AuthenticationServiceImpl implements AuthenticationService
    private UserDAO userDAO;
    public AuthenticationServiceImpl()
        // Create a database connection here and the UserDAO, too.
    public boolean isAuthorized(String username)
        boolean isAuthorized = false;
        // Add logic to do the database query and decide if the username is authorized
        return isAuthorized;       
}

Similar Messages

  • Can I use Java Creator 2 with old JRE/JDK 1.4.2_07??

    I am planning to install new Java Creator 2 but I am having JRE and JDK 1.4.2_07 and I am using mysql 3.23.55 and I want to integrate it.
    Currently my OS is Windows XP SP2 platform with processor Intel Centrino 1.4 and RAM 256 MB... I know the ram is not sufficient and i am planning to upgrade it.. but the problem is can i still remain to use the old JRE and JDK 1.4.2_07 and i am also using mysql 3.23.55... all the driver and engine are out to date but can i still use it and integrate it with java creator 2?
    The questions are:
    1) Can I use Java creator 2 with those old engine?
    2) What java compiler or development tools i can use to develop java standalone application?
    Thank you

    When the jar file is expanded within Eclipse, it shows that the mail.jar file is built with 1.5.0; I think? Here is the header contents of the MANIFEST.MF file, note "Created by."
    Manifest-Version: 1.0
    Implementation-Version: 1.4
    Specification-Title: JavaMail(TM) API Design Specification
    Specification-Version: 1.3
    Implementation-Title: javax.mail
    Extension-Name: javax.mail
    Created-By: 1.5.0 (Sun Microsystems Inc.)
    Implementation-Vendor-Id: com.sun
    Implementation-Vendor: Sun Microsystems, Inc.
    Specification-Vendor: Sun Microsystems, Inc.
    SCCS-ID: @(#)javamail.mf     1.6 05/12/09
    This is causing problems, because anytime I try to use this file, I get signing errors. I have several Web Services built by BAE and Plumtree that are running on 1.4.2; and therefore I am stuck with 1.4.2. I did try to remove the SUN_MICR.* files, thinkning it would resolve the signing issues, but then that caused other problems. I can provide you with code that demonstrates the problem.
    Is there a place where I can get a mail 1.4 jar file built with 1.4.2? that would most likely solve my problems.

  • Can I use Web Services with Microsoft Access?

    I'm somewhat handy with Microsoft Access (2003 in particular), but not an expert. Macros? No problem. VBA? I'd be hard pressed to code anything from scratch, but I'm not too bad with modifying code/examples to fit my particular scenario. So, if anything about this doesn't ring quite right, now you'll know why. Some years ago I worked with another guy to develop a module that used REST(?) to query some web services at Yahoo!. If that worked, I was hoping that I could do similar things with CRMOD I was thinking, for example, I might want to get the Opportunity Sales Stage for a number of records. And since there are tools for Excel and Word, I thought Access might work, too. As a starting point, I imagine I need to use the Web Services Toolkit for Office 2003. But frankly, I don't even know where to go beyond that.
    Am I wasting my time? Any suggestions for an intro to web services?

    Probably not through USB.
    But likely if its anytihng like the Microsoft Sync in my Ford Explorer you can play audio from it through Bluetooth.
    You can read here for compatibilites, and features.
    http://www.ford.com/technology/sync/
    I connect My iPad to the Sync media center with no issues and can play my musci from the iPad thorugh the car stereo speakers.

  • Using Java SE 6 with Java FX 2.2 on Mac OS X

    Hello,
    Has anyone tried using Java SE 6 with JavaFX 2.2 on Mac OS X?
    JavaFX 2.2 System Requirements doc states that "For Mac OS X, use Java SE 7 Update 6 for Mac OS X. JavaFX 2.2 has not been formally tested with Apple's Java SE 6 implementation for Mac OS and support is offered only when used with Java SE 7 Update 6 or later.".
    So I guess that means Java SE 6 may or may not work well with JavaFX 2.2 on Mac.
    For some 'bugs' in my app, they simply don't exist if I switch from Java 7 to Java 6?
    One such bug is mentioned in this thread: Re: Unable to play mp3 files with non-English alphabets/characters in the name
    Can people with experiences in this area please share your thoughts?
    Has Oracle done additional Java SE 6 and JavaFX 2.2 compatibility testings since the JavaFX 2.2 System Requirements doc was published (http://docs.oracle.com/javafx/2/system_requirements_2-2/jfxpub-system_requirements_2-2.htm)?
    Thanks.

    Java 6 on Mac is not supported officially and not going to be supported.
    Standalone JavaFX app might work as JDK 6 on Mac was used as dev platform before JDK 7 on Mac became available.
    But this was mostly on older Mac OS X version (up to 10.6) and you may easily hit something that was fixed in Java 7 to support JavaFX better.
    Webstart/Plugin will not work. You need JRE 7 from Oracle.

  • Execute MSIL code using JAVA

    How can I execute MSIL code using java?

    Thanks for your reply. I did it in google and didn't find any useful think.
    I just want to know is there any technique in java or already written product that can do that.
    Any advice will be helpful. Thanks

  • Appleworks Database vs. Microsoft Access

    I currently manage my database on a PC with Microsoft Access. I would like to switch the data to my new iMac (1.83 GHz Intel Core Duo, OS 10.4). Can anyone tell me more about the database program in Appleworks? Can you customize the fields (to include more than just the basic name, address, etc fields) or are they pre-set? Also, can you create searches within the program (ie to find a record based on a last name)? I am trying to avoid buying FileMaker Pro because of it's higher cost. Any information and details about the program's capabilities would be greatly appreciated!
    Thanks!
    iMac 1.83GHz Intel Core Duo   Mac OS X (10.4.7)  

    I currently manage my database on a PC with Microsoft
    Access. I would like to switch the data to my new
    iMac (1.83 GHz Intel Core Duo, OS 10.4). Can anyone
    tell me more about the database program in
    Appleworks? Can you customize the fields (to include
    more than just the basic name, address, etc fields)
    or are they pre-set? Also, can you create searches
    within the program (ie to find a record based on a
    last name)? I am trying to avoid buying FileMaker Pro
    because of it's higher cost. Any information and
    details about the program's capabilities would be
    greatly appreciated!
    Yes, you can do all of those things: define fields including name, type..., and you can create/save searches on the database. To see examples of people doing these things do a search in Google using a phrase like:
    appleworks +database +tutorial
    You're probably aware of this, but I'll mention it just in case: AppleWorks is no longer bundled with any Macs, and must be purchased separately.
    Also, AppleWorks has a flat-file database. This is basically a single table of records. However, Access is a relational database and creates multiple tables of records which can be linked together using key fields. If your Access database is a relational database then you will have to redesign it work in AppleWorks. That is, collapse it all into one big table. If you're reasonably serious about databases, then you'll find FileMaker is a better choice. It is a relational database very similar to Access, and will create smaller more efficient databases than AppleWorks. NB There are other relational databases available on the Mac too. So search VersionTracker.com for the alternative products.
    Lastly, AppleWorks will not open your Access database. You will have to save the data from the Access database into a tab-separated value text format so it can be imported into AppleWorks. Because you're saving the data into a text format you will not be able to use the screens you've created in Access, and will have to recreate them in AppleWorks.
    Dale

  • Open a Microsoft Access file using LV

    Hi, 
        When my VI finishes executing I would like it to Open up a Microsoft Access file and delete an Excel Table.  I have gotten it to delete the Excel Table, however, it will not open the Access file.  I have tried using Open File and I have tried open/create/replace, but they are not working.  I am almost positive I am putting the directory and file extentsion right as well.  I am using LV 6.1.  
    Thanks 

    I have recently added data-basing using labview and access.  I am using labview 7.0 and the DB toolkit.  I have no problem connecting to access using the jet 4.0 engine, where I can read modify and edit access data.  What are you trying to delete? a table, remove entries or delete the entire file itself.  There are two ways to connect to access, using an activeX control or through ODBC.  I have never used activeX for access but have used it for excel, this was not too difficult but there is a lot of methods and properties to wade through to get things working.  I might be able to help you, but will need a little more info on what you need to do with access.  Using the DB toolkit and ODBC, you will not need access on the machine to use the database, which is a nice option if you plan on distributing the application.  I am a DB novice but have been learning fast, I think Mike Porter knows alot about labview and database connectivity, hopefuly he will help out here.
    Paul
    Paul Falkenstein
    Coleman Technologies Inc.
    CLA, CPI, AIA-Vision
    Labview 4.0- 2013, RT, Vision, FPGA

  • How can I open encrypted Microsoft access files on a mac?

    How can I open an encryted Microsoft access file on an iMac?

    As Office for Mac doesn't include Access, I'm not at all sure you can.
    You could try Open Office, NeoOffice or Libre Office (all free, open source) and see if their database applications can do it.

  • Connection with Microsoft Access using Java on Linux

    Hi,
    I am very new to Linux & trying to move my application from Windows to Linux.
    I am downloading one database(*.mdb) file from an url & want to select records from tables & add them to my My Sql database.
    Is there any way to connect to Access database on Linux machine ( Without using different Windows machine having Ms Access installed).
    Thanks in advance.
    Regards,
    Veena

    I am having the same problem.
    jackcess worked fine with Access 2000.
    But i want to work with Access having previous version (probably 97).
    Is there any way to do this?

  • How to link dataTable component with Microsoft Access Database?

    Please mail me @ [email protected]

    Creator might not support MS Access yet but use this code for an access database connection will always work even through notepad or textpad:
    import java.io.BufferedInputStream;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.InputStream;
    import java.util.Properties;
    * @author Mark Hennessy
    public class MyDataSource {
    private static MyDataSource ds = null;
    private static java.sql.Connection connection = null;
    /** Creates a new singleton instance of MyDataSource */
    private MyDataSource() {
    try{
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    connection = java.sql.DriverManager.getConnection("jdbc:odbc:<db name>", "guest", "guest");
    }catch(ClassNotFoundException cnf){
    cnf.printStackTrace();
    }catch(java.sql.SQLException sqle){
    sqle.printStackTrace();
    public static DataSource getInstance() {
    if(ds == null)
    ds = new DataSource();
    return ds;
    public java.sql.Connection getConnection() {
    return this.connection;
    public static void closeConnection() {
         try{
              connection.close();
         }catch(java.sql.SQLException sqle){
              sqle.printStackTrace();
    plus set up the ODBC connection via click start , click run and then copy and paste the following "odbcad32.exe" without the quotes, click ok, click user DSN tab, click Add...button select Microsoft Access Driver (*.mdb) click finish, give <db name> name of ur access database, give any description <whatever> or leave blank click the select... button navigate to the access database u want to connect to in your java code and select it.
    in calling program
    public class CustomersImplimentation {
    private static java.sql.Connection connection = null;
    private java.sql.ResultSet rs = null;
    public CustomersImplimentation(){
    connection = MyDataSource.getInstance().getConnection();
    public Customers[] findAll(){
    java.util.ArrayList list = new java.util.ArrayList();
    String sql = "SELECT * FROM CUSTOMERS";
    try{
    java.sql.Statement stmt = connection.createStatement();
    rs = stmt.executeQuery(sql);
    while(rs.next()){
    list.add(new Customers(rs.getInt(1), rs.getString(2), rs.getString(3)));
    }catch(java.sql.SQLException sqle) {
    System.out.println((new StringBuilder()).append(
    "SQLException :: executeQuery Cannot find all Customers:").append(sqle).toString());
    Customers[] customers = new Customers[list.size()];
    for(int i = 0; i < list.size(); i++){
    customers[i] = (Customers)list.get(i);
    return customers;
    if you have a Customers class created with set and get methods and a constructor that takes an int string string i.e.
    public Customers(int ID, String firstName, String lastName){}
    then u should be able to run these classes from within creator with an access database. hope this helps?
    regards
    Henno

  • Bad performance when using  complex database view with Toplink

    Hi
    Problem description
    1. I have a complex query that collects the data from many DB tables. For this reason I create a database view based on this select. Using EJB 3.0 with Toplink I
    mapped this view to a java object the same way I map database tables. The method I use to get the results is:
    snippet code...
    public List<VwKartela> VwKartela(Integer pperid) {
    List<VwKartela> results = null;
    Session session = getSessionFactory().acquireSession();
    ExpressionBuilder bankfile = new ExpressionBuilder();
    Expression exp1 = bankfile.get("perid").equal(pperid);
    ReadAllQuery query = new ReadAllQuery();
    query.setReferenceClass(VwKartela.class);
    query.setSelectionCriteria(exp1);
    results =(List<VwKartela>)session.executeQuery(query);
    When running the select on the view prom SQL Plus I haven’t any performance problem.
    2.Question: How can I improve the performance? I referenced to Toplink docs but I didn't improve the it.
    Have anyone any experience is such cases?
    Thank you
    Thanos

    Hi
    After my last tests I conclude at the followings:
    The query returns 1-30 records
    Test 1: Using Form Builder
    -     Execution time 7-8 seconds
    Test 2: Using Jdeveloper/Toplink/EJB 3.0/ADF and Oracle AS 10.1.3.0
    -     Execution time 25-27 seconds
    Test 3: Using JDBC/ADF and Oracle AS 10.1.3.0
    - Execution time 17-18 seconds
    When I use:
    session.setLogLevel(SessionLog.FINE) and
    session.setProfiler(new PerformanceProfiler())
    I don’t see any improvement in the execution time of the query.
    Thank you
    Thanos

  • Website use Java but not support Microsoft JVM

    This website (www.esdlife.com.hk) only support Microsoft JVM but not Sun JAVA JVM, I can't logon into their service pages until I disable my Sun JVM or unless I use another computer it has Microsoft JVM installed. Those pages even don't let me use other web browser like Netscape except Internet Explorer. I am an amateur Java programmer and I have been studying Java for three years. I don't know if this is an issue to the future of Java Technology. This website supported by the Hong Kong government I believe. Could anyone response my question?
    Thanks in advance!
    Peter
    [email protected]

    What has probably happened is that the site you are talking about wrote thier page with Microsoft Java, which isn't really Java. They probably used some class, or number of classes, that is specific to the Microsoft VM. This is not a problem with Java, it is a problem with Microsoft makeing their Java uncompatible with Java.

  • Using Java 1.5 with TopLink Mapping Workbench 10g(9.0.4.9) - Exception

    We're getting a ExternalClassNotFoundException when refreshing classes in 10g(9.0.4.9) workbench. The classes were recently compiled in JAVA 1.5. We have just migrated from RAD6 using Java 1.4 to RAD8 using Java 1.5. Is there a way to use this verion of the workbench with JAVA 1.5? Or is our only alternative to upgrade to a later version on the workbench.

    I strongly suggest to upgrade to AS 10.1.3 to get this.
    Think of future support of AS 9.0.4. You will get not critical patch updates anymore.
    --olaf                                                                                                                                                                                                                                                                                                               

  • Invoke exe through java code(using java.lang.Runtime)

    Iam trying to invoke an exe from java code.If i give the complete path for that exe it is running fine .But if i set the environment variable and directly execute the exe through command prompt it iss running fine , but it fails to run when i do the same using java code i.e. java.lang.Runtime.exec function

    Give "//" for directory seperator.
    E.g. r.exec("c://test//test.exe",null);
    Why? That doesn't look correct.It is correct. It will work fine. Try it out.But it doesn't add or solve anything. A forward slash
    does not need to be escaped.'
    It's not even escaping. It's just doubling up. If that works, I'd bet "C://///test///////test.exe" does also.

  • Problem using Java Mail API with WLS 7.0

    Hi All,
    I am trying to use the Java Mail API provided by WLS 7.0. I have made the
    settings metioned in the WLS 7.0 docs. However when I try to run the program I
    am getting the following error:
    javax.naming.NoInitialContextException: Need to specify class name in environment
    or system property, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    46)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:283)
    at javax.naming.InitialContext.lookup(InitialContext.java:350)
    The code that I have written is as follows
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
         public static void main(String args[])
              try
                   //Context ic = getInitialContext();
                   InitialContext ic = new InitialContext();
    /* My jndi name is "testSession" */
                   Session session = (Session) ic.lookup("testSession"); /* THE PROBLEM IS SHOWN
    IN THIS LINE */
                   Properties props = new Properties();
                   props.put("mail.transport.protocol", "smtp");
                   props.put("mail.smtp.host", "XX.XX.XX.XX");
    /* For security reasons I have written the ip add in this format */
                   props.put("mail.from", "[email protected]"); /* for security reasons i have
    changed the mail address */
                   Session session2 = session.getInstance(props);
                   Message msg = new MimeMessage(session2);
                   msg.setFrom();
                   msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]",
    false));
                   msg.setSubject("Test Message");
                   msg.setSentDate(new Date());
                   MimeBodyPart mbp = new MimeBodyPart();
                   mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
                   Multipart mp = new MimeMultipart();
                   mp.addBodyPart(mbp);
                   msg.setContent(mp);
                   Transport.send(msg);
              catch(Exception e)
                   e.printStackTrace();
         }//end of main
    public static Context getInitialContext()
         throws NamingException
              Properties p = new Properties();
              p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
              p.put(Context.PROVIDER_URL, "t3://localhost:7501/testWebApp");
                   p.put(Context.SECURITY_PRINCIPAL, "weblogic");
                   p.put(Context.SECURITY_CREDENTIALS, "weblogic");
              return new InitialContext(p);
    }//end of class
    Can anyone please tell me what is the problem. I thought that we cannot directly
    do
    InitialContext ic = new InitialContext();
    So I had written a method getInitialContext() as shown in the above piece of code,
    but that too did not work.
    Eagerly awaiting a response.
    Jimmy Shah

    You can use InitialContext ic = new InitialContext() only if you are using a startup class, servlet or a JSP i.e
    server side code.
    If you are using a java client you need to use Context ic = getInitialContext();
    Try this code
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
    public static void main(String args[])
    try {
    Properties h = new Properties();
    h.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
    h.put(Context.PROVIDER_URL, "t3://localhost:7001");
    Context ic = new InitialContext(h);
    Session session = (Session) ic.lookup("testSession");
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", "XX.XX.XX.XX");
    props.put("mail.from", "[email protected]");
    Session session2 = session.getInstance(props);
    Message msg = new MimeMessage(session2);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse("[email protected]",false));
    msg.setSubject("Test Message");
    msg.setSentDate(new Date());
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    Transport.send(msg);
    catch(Exception e)
    e.printStackTrace();
    }//end of main
    }//end of class
    We have shipped a javamail example in the samples\server\src\examples\javamail folder.
    Jimmy Shah wrote:
    Hi All,
    I am trying to use the Java Mail API provided by WLS 7.0. I have made the
    settings metioned in the WLS 7.0 docs. However when I try to run the program I
    am getting the following error:
    javax.naming.NoInitialContextException: Need to specify class name in environment
    or system property, or as an applet parameter, or in an application resource file:
    java.naming.factory.initial
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    46)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:246
    at javax.naming.InitialContext.getURLOrDefaultInitCtx(InitialContext.jav
    a:283)
    at javax.naming.InitialContext.lookup(InitialContext.java:350)
    The code that I have written is as follows
    import java.util.*;
    import javax.activation.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.naming.*;
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    public class MailTo {
    public static void main(String args[])
    try
    //Context ic = getInitialContext();
    InitialContext ic = new InitialContext();
    /* My jndi name is "testSession" */
    Session session = (Session) ic.lookup("testSession"); /* THE PROBLEM IS SHOWN
    IN THIS LINE */
    Properties props = new Properties();
    props.put("mail.transport.protocol", "smtp");
    props.put("mail.smtp.host", "XX.XX.XX.XX");
    /* For security reasons I have written the ip add in this format */
    props.put("mail.from", "[email protected]"); /* for security reasons i have
    changed the mail address */
    Session session2 = session.getInstance(props);
    Message msg = new MimeMessage(session2);
    msg.setFrom();
    msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse("[email protected]",
    false));
    msg.setSubject("Test Message");
    msg.setSentDate(new Date());
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText("This is a mail sent to you using JAVA Mail API and Weblogic Server");
    Multipart mp = new MimeMultipart();
    mp.addBodyPart(mbp);
    msg.setContent(mp);
    Transport.send(msg);
    catch(Exception e)
    e.printStackTrace();
    }//end of main
    public static Context getInitialContext()
    throws NamingException
    Properties p = new Properties();
    p.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
    p.put(Context.PROVIDER_URL, "t3://localhost:7501/testWebApp");
    p.put(Context.SECURITY_PRINCIPAL, "weblogic");
    p.put(Context.SECURITY_CREDENTIALS, "weblogic");
    return new InitialContext(p);
    }//end of class
    Can anyone please tell me what is the problem. I thought that we cannot directly
    do
    InitialContext ic = new InitialContext();
    So I had written a method getInitialContext() as shown in the above piece of code,
    but that too did not work.
    Eagerly awaiting a response.
    Jimmy Shah--
    Rajesh Mirchandani
    Developer Relations Engineer
    BEA Support

Maybe you are looking for