MyEclipse ways to add a SQL Server 2008 database
In general, when configuring the environment, if you want to use the database, you need to connect the programming tools with the database. Now, the small series for you to introduce, myeclipse add SQL Server 2008 Database method, we hope to help
1, in the environment variable, add Sqljdbc.jar path under CLASSPATH (can directly copy Sqljdbc.jar to JDK directory)
2, set up the SQLExpress server, start the TCP/IP service (skip this step if it is turned on), restart the server
3. In MyEclipse, Window---Preferences----and Java-to-installed JREs, click Edit to add the existing jar and select the previous Sqljdbc.jar.
4, the configuration is complete, when creating a new Web project will automatically add this database connection
5. Select a project right-click Test in the Catalog window, select Build Path---Configure build path ..., add extension jar file, add Sqljdbc.jar to it
6. Write Java code to test the connection database
Import java.sql.*;
public class Test {
public static void Main (string[] SRG) {
String drivername = "Com.microsoft.sqlserver.jdbc.SQLServerDriver"; Loading the 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 ();
}
}
}
MyEclipse ways to add a SQL Server 2008 database