Forum Stats

  • 3,874,546 Users
  • 2,266,752 Discussions


java.sql.SQLException: ODBC Driver Manager

Sruthi Member Posts: 31

I am new to JSP & Web tech. I am trying to access SQL server from validation.jsp. The piece of code used for the same is given below. TestDSN is the System DSN I have added in ODBC Data Source Administrator(All Control Panel Items\Administrative Tools). I am using Tomcat 7.

String user=request.getParameter("t1");
String pass=request.getParameter("t2");


Connection test=DriverManager.getConnection("jdbc:odbc:TestDSN","sa","abcd");
Statement st=test.createStatement();
String sqlQuery = "Select username,password from dbo.userlog where username=\'" + user + "\'";
ResultSet rs=st.executeQuery( sqlQuery );
int userflag = 0;


I am able to access database and do the validation and get the direction to next page in my 32 bit PC (Windows 7). But while trying the same from 64 bit PC, the following message is thrown *"Error occurred java.sql.SQLException: [Microsoft][ODBC Driver Manager] The specified DSN contains an architecture mismatch between the Driver and Application"*

Could you please help me.

Thank you.


  • EJP
    EJP Member Posts: 32,937 Gold Crown
    If you are using 32-bit Java on 64-bit Windows you need to define a DSN using the 32-bit ODBC driver in the ODBC Data Source Administrator.
  • DrClap
    DrClap Member Posts: 25,479
    Could I point out a few bad practices in your posted code?

    (1) Using scriptlets in a JSP.

    (2) Using the JDBC-ODBC driver to access a database other than MS Access.

    (3) Generating SQL via string concatenation instead of using a PreparedStatement.

    I'm also willing to guess that you have done these further bad practices, although your posted code doesn't clearly demonstrate them:

    (4) Storing passwords in clear-text in the database.

    (5) Failing to close your connections in a finally-block.

    As you say, you are learning Java-based web technologies. But really, you have started out quite badly. I would suggest you seek out some more experienced supervision to lead you into better habits.
  • Sruthi
    Sruthi Member Posts: 31

    Thanks for the hint. I was using 32 bit Java & 32 bit Tomcat. Using 64 bit versions the error is no more seen.

    Few more info:


    Thanks for the detailed suggestions too. Unfortunately it happened to be my first jsp & was trying to extend a java program and see the outcome.

    Thank you.
This discussion has been closed.