MyEclipse Configure SQL Server 2008 database-driven operation steps _mssql2008

Source: Internet
Author: User

1, in the environment variable, under the Classpath add Sqljdbc.jar path (can be copied directly sqljdbc.jar to the JDK directory)

2, set up SQLExpress server, start TCP/IP services (if you have skipped this step), restart the server

3. In MyEclipse, window--> Preferences--> Java--> installed JREs

Click Edit, add the existing jar after entering, and select the previous Sqljdbc.jar

4, configuration complete, when a new Web project will automatically add this database connection

5. Select an item right-click Test in the Table of Contents window, select Build path--> Configure builds path ..., add extension jar file, add Sqljdbc.jar to

6, write Java code to test the connection database

Copy Code code as follows:

Import java.sql.*;
public class Test {
public static void Main (string[] SRG) {
String drivername = "Com.microsoft.sqlserver.jdbc.SQLServerDriver"; Load JDBC Driver
String Dburl = "jdbc:sqlserver://localhost:1433;" Databasename=information ";
String userName = "sa";
String userpwd = "123";
Connection Dbconn;
try {
Class.forName (drivername);
Dbconn = Drivermanager.getconnection (Dburl, UserName, userpwd);
System.out.println ("Connection successful!");
catch (Exception e) {
E.printstacktrace ();
}
}
}

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.