Java.sql.SQLException: [MICROSOFT][ODBC Driver Manager] in the specified DSN, the architecture between the driver and the application does not match

Source: Internet
Author: User
Tags driver manager dsn

Today, SQL Server R2 installed, 64-bit, and then can't wait to experience the operation of the connection database, programming language is java. I began to learn a very old connection, using the Jdbc-odbc bridge. The first use is not very skilled, so the detailed steps are written down here.

The first is to configure the ODBC data source, open the Control Panel, small icon way to view, I see there is a

This icon is like a 32-bit ODBC flag, I clicked start it, but started the 64-bit ODBC management tool,

I clicked the Add button under the User DSN panel to bring up the Create New Data Source window,

I double click on "SQL Server", pop up the following window

I fill in the "Name" column "Hp4", in the "Server" column "(local)" (The server column can be selected from the drop-down menu, the drop-down list is empty when the "(local)" or the computer name, the computer name can be seen in the computer properties), and then the next

Come to the following window, select "Use user input login ID ...", login name "sa", password fill in the sa account password, next

Continue to the next to complete, pop-up configuration information, you can test the next data source

So far, the data source configuration is complete.

Next start MyEclipse, create a new Web project, add a SQL package reference to index.jsp, pageencoding set to "Utf-8"

Add the following code inside the body:

<%

try{

Connection Con;

Class.forName ("Sun.jdbc.odbc.JdbcOdbcDriver");

Con = Drivermanager.getconnection ("Jdbc:odbc:hp4", "sa", "123456");

System.out.println ("Step1 goes Well");

}

catch (Exception e) {

System.out.println ("Step1 down");

E.printstacktrace ();

}

%>

To access the above page in the MyEclipse built-in browser, the console output "STEP1 goes Well" indicates a successful connection.

The Jdbc-odbc Bridge is built into the JDK, so there is no need to add a driver package, the code above means that the connection succeeds on the console output "STEP1 goes well", the connection error is in the console output "Step1 down".

The process of creating a data source I still have a lot of questions.

First, should you start the ODBC Administrator 32-bit or 64-bit?

Click on "Administrative Tools" in the Control Panel and you will see two ODBC managers,

In this demo I started with 64-bit,

Then, do you want to create a new data source under the User DSN panel or under the System DSN panel?

I previously created two data sources under the System DSN panel, and the connection was error-

Java.sql.SQLException: [MICROSOFT][ODBC Driver Manager] in the specified DSN, the architecture between the driver and the application does not match

I baidu this error, online said is because of 32-bit and 64-bit problems, 64-bit system should establish 64-bit DSN, but I was established under the System DSN DSN is 64-bit, for example, connect the following two DSN will report the above error.

The DSN I created under the User DSN panel appears to be supported by both 32-bit and 64-bit, such as HP2, HP3, HP4

There are no other problems. The above two problems are too lazy to discuss, very simple control variable method can be checked out.

Java.sql.SQLException: [MICROSOFT][ODBC Driver Manager] in the specified DSN, the architecture between the driver and the application does not match

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.