Use eclipse and link MSSQL database Xiaogan in eclipse

Source: Internet
Author: User
Tags microsoft website
I recently tested eclipse and was quite touched.

It is not difficult to download eclipse3.2.0 from a website. It takes some effort to download a Chinese package. It is only successful if you use Chinese for the first time. It also took some twists and turns. It was discovered that this thing was not completely developed, and there was no wings or legs. It was just a single shot, and visual programming still needed plug-ins, so it was difficult. I am still satisfied with Eclipse, but the concept of minimizing the left and right sides of the Panel has been stolen, so it should be moderate.

Connecting MSSQL in eclipse can be difficult. I copied two examples from the Internet. None of them can run successfully. The original configuration is as follows.

1. Download and install Microsoft SQL Server 2000 driver for JDBC from the Microsoft website.
2. Introduce the three MSSQLServer. jar, msbase. jar, and msutil. Jar under the installed directory lib to the Eclipse project.
Iii. Introduction Method
Right-click the project and choose Properties> JAVA build path> database> Add external jar.
4. Run the following statement:


Import Java. SQL. * ;

Public   Class Connetiontest {
Public   Static   Void Main (string [] ARGs) {
// String drivername = "net. SourceForge. jtds. JDBC. Driver ";
// String dburl = "JDBC: jtds: sqlserver: // 127.0.0.1: 1433; databasename = pubs ";

String drivername =   " Com. Microsoft. JDBC. sqlserver. sqlserverdriver " ;
String dburl =   " JDBC: Microsoft: sqlserver: // 127.0.0.1: 1433; databasename = pubs; " ;


String Username =   " SA " ;
String userpwd =   "" ;
Connection dbconn;
Try   {
Class. forname (drivername );
Dbconn=Drivermanager. getconnection (dburl, username, userpwd );
System. Out. println ("Connection successful!");
}
Catch (Classnotfoundexception E) {
System. Out. println ("Error: class:"+E. getmessage ());
}
Catch (Sqlexception SQL) {
System. Out. println ("SQL:"+SQL. getmessage ()+"Stte:"+SQL. getsqlstate ());
}

}

}

You can run it.

Related Article

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.