0

I already made my ODBC connection, but it still wont work.

Kindly guide along the way, please and thank you

Here is my code below:


package payrollapplication;
import java.sql.*;
import javax.swing.*;


/**
 *
 * @author Admin
 */
public class DBConnection {
    boolean ISCONN=false;
    boolean ISSUCC=false;
    boolean ISCONFIRM=false;


    private String NextNumber="";

    Connection Conn;
    PreparedStatement ps;
    ResultSet rs;
    Statement st;
    /** Creates a new instance of DBConnection */
    public DBConnection()
    {
        ConnectToDatabase();
    }

     public boolean ConnectToDatabase()
    {
        try
        {
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            Conn=DriverManager.getConnection("jdbc:odbc:Employee");
            ISCONN=true;

        }
        catch(Exception ex)
        {
            JOptionPane.showMessageDialog(null,ex,"CONNECTION",JOptionPane.ERROR_MESSAGE);
        }

        return ISCONN;
    }

     public String getNumber()
     {
         return NextNumber;         
     }

     public void setNumber(String NXTNO)
     {
         int n;
        n=Integer.parseInt(NXTNO)+1;


         NextNumber="" + n + "";
     }

     public void  LoadEmpNo()
     {
         String SQLMax;
           try
           {
               SQLMax="SELECT Max(Emp_No) FROM MS_Employee";
              st=Conn.createStatement();
              rs=st.executeQuery(SQLMax);

              if (rs.next())
              {
                  setNumber(rs.getString(1));

              }

           }
           catch(Exception ex)
           {

           }
 }

     public boolean  FindEmployee(String SQLFIND)
     {
         try
         {
             st=Conn.createStatement();
             rs=st.executeQuery(SQLFIND);

             if (rs.next())
             {
                 ISCONFIRM=true;
             }
             else
             {
                 ISCONFIRM=false;
             }

         }
         catch(Exception ex)
         {
             ISCONFIRM=false;
         }
         return ISCONFIRM;
     }

     public boolean Add_Update_EmpMaster(String SQL,boolean ISADD_OR_UPDATE)
     {
       try
       {
         ps=Conn.prepareStatement(SQL);
         ps.executeUpdate();
         ISSUCC=true;
        }
       catch(Exception ex)
       {
          //  JOptionPane.showMessageDialog(null,ex,"CONNECTION",JOptionPane.ERROR_MESSAGE);
            ISSUCC=false;
       }

       return ISSUCC;
     }

}

This is the error that popped up:

java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application
Mohammad Ashfaq
  • 1,333
  • 2
  • 14
  • 38
drew
  • 3
  • 1
  • http://social.technet.microsoft.com/Forums/office/en-US/62665fd9-008f-4b78-9b36-2f61007a77b7/javasqlsqlexception-microsoftodbc-driver-manager-the-specified-dsn-contains-an-architecture?forum=officeitproprevious and http://stackoverflow.com/questions/8895823/the-specified-dsn-contains-an-architecture-mismatch-between-the-driver-and-appli – StanislavL Mar 10 '14 at 07:39
  • Try to use this URL format: `jdbc:sqlserver://DATABASE_HOST\\INSTANCE_NAME;databaseName=DATABASE_NAME` – Salah Mar 10 '14 at 07:41
  • You should see this : http://stackoverflow.com/questions/8895823/the-specified-dsn-contains-an-architecture-mismatch-between-the-driver-and-appli – Mohammad Ashfaq Mar 10 '14 at 07:43
  • we;; i resolved the mismatch part, but now my error is is the DSN not found and no default driver specified. T_T – drew Mar 10 '14 at 07:51

1 Answers1

1

You will need 64-bit drivers if your Java is 64-bit.