Results 1 to 2 of 2
  1. #1
    ravidasineni is offline Member
    Join Date
    Nov 2009
    Rep Power

    Default problem with connecting database

    I am staring a new project with swing application framework in netbeans in that i selected newproject->java - java desktop application - basic application-> finish.

    In that i started doing project in a view class, in that class i take two textboxes and one button to design login page.From that class i connect a database connection to check the textboxes values.the driver is loaded successfully and connection is not connected to database in that class only.

    From that project when i take a new class in that i can connect database successfully and retrive the values.I add all libraries and jar files.plz check the following code and help me.I wrote the following code under the button.

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    // getting textbox values.

    String us = u.getText();
    String vs = p.getText();

    System.out.println("username " + us);
    System.out.println("password "+vs);
    // values retrived successfully.

    try {
    //connecting database

    Class.forName(" verDriver");
    System.out.println("driver loaded........");
    // driver loaded successfully.

    // from hear process is not done...
    con = DriverManager.getConnection("jdbc:sqlserver://java04:1433;databaseName=appforum;userName=sa");

    stmt = con.createStatement();
    System.out.println("statement created.");
    rst = stmt.executeQuery("select userName,Password from SwingsUser where UserName='" + us + "' and Password='" + vs + "'");
    System.out.println("resultset created.");
    if ( {
    r = rst.getString("UserName");
    rs = rst.getString("Password");
    System.out.println("retrieving username,password.");

    if (us.equals(r)) {
    if (vs.equals(rs)) {

    //going to next page

    j = new NewJFrame();
    } catch (Exception e) {



    driver loaded..... after that process is running and structed the form

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power


    Duplicate thread. OP: please don't multipost. Choose the one best forum for your question and post it there. I've locked the other thread.

    Thank you for your cooperation.

Similar Threads

  1. Replies: 0
    Last Post: 12-24-2008, 10:35 AM
  2. Problem in connecting to database..
    By Preethi in forum New To Java
    Replies: 10
    Last Post: 06-26-2008, 05:53 AM
  3. problem in connecting to mysql database
    By nancyv in forum Java Servlet
    Replies: 6
    Last Post: 04-02-2008, 11:33 AM
  4. Problem connecting to my Database using Java
    By javaneed in forum New To Java
    Replies: 3
    Last Post: 08-13-2007, 09:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts