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 ();
}
}
}