Server these days started for the Red Fung Office website to do the preparatory work, the first is the SQL Server JDBC Connection debugging good. First download a lot of source code files. such as online news release system, community management system, and so on, a variety of use of SQL Server JSP source code. Started my long and frustrating database connection work.
First make sure that the tool I use is Eclipse 3.2 + Tomcat 6.0 + jdk1.6, and the operating system is Windows XP SP2.
Step one: Install SQL Server 2000 (I started installing SQL Server 2000, then when I installed. NET, I chose not to know which key, and I could install SQL Server 2005, and I have two versions of SQL Server.) Even more exasperating is that I did it for a long time before I realized I have two versions of SQL server! Faint!!!! )。 Be sure to patch, at least if the SP3 of SQL Server patch, the download address of this patch is http://www.cnd8.com/soft/3532.htm. SP4 Patch address is http://www.skycn.com/soft/13307.html, the best is the Thunderbolt download, my speed is 1-2m/s, hehe, the campus network is strong AH!! I also made a fatal mistake when I installed the patch, and it took me a long time to find out why.
I am in the installation of patches, think so easy to finish, immediately restart the machine, debugging, the result is not successful, because I just did the action is actually only a package of decompression, the real installation work has not begun.
Only click on the C disk in the Sql2ksp3 folder in the Setup.bat after the real installation began. We do not laugh ah, I do keenness, have not seen such installation procedures, so in this miss! Seung-so!! Once the installation is complete, start our next step, with the JDBC configuration of Eclipse.
Step Two: Configure the database connections under Eclipse and the JDBC settings.
1. First download the database query plug-in for Eclipse: Sqlexplorer.
Plug-in introduction:
Sqlexplorer is a plug-in for the Eclipse integrated development environment that can be used to connect to a database from Eclipse. The Sqlexplorer plug-in provides a graphical user interface (GUI) that accesses a database using SQL statements. Through using Sqlexplorer, can display table, table structure and table data, as well as extract, add, update or delete except tabular data. Sqlexplorer can also generate SQL scripts to create and query tables. Therefore, using sqlexplorer may be a better choice than a command-line client.
Detailed installation steps (illustrated) see HTTP://WWW.BLOGJAVA.NET/KRISTEN/ARCHIVE/2006/07/20 ... (Don't look at the later part of the article), the article describes more detail. Installing Eclipse Plug-ins is also a hassle. Personally think the better or use link way. This is easy to manage and facilitates later upgrades to the new version of the migration. It's important to be careful about choosing the right version, such as what your eclipse is, and what kind of sqlexplorer to choose from.
2. Install the JDBC driver for SQL Server 2000. There are two choices, the online comparison recommended is Jdts, its download address is: Http://file.tianwang.com/cgi-bin/search?word=jtds, the specific configuration is http://blog.csdn.net/raykcn/ Archive/2006/11/13/1380952.aspx, we can refer to.
Microsoft's official download address is HTTP://WWW.MICROSOFT.COM/DOWNLOADS/DETAILS.ASPX?FA ....
Executes the Ms_jdbc_setup.exe executable file. Until the installation is complete.
(1) Ms_jdbc_setup default installation path is: c:\Program Files\Microsoft SQL Server Driver for JDBC
(2) installation directory \lib\ three jar files that is the JDBC drive core we want
Msbase.jar
Mssqlserver.jar
Msutil.jar
Note: The driver jar file for the Microsoft SQL Server sqljdbc.jar JDBC driver has only one name, but it can replace the three jar files in 2000. The web says it can be used under SQL Server 2000. I don't know what the situation is, I haven't tried it. The official download address of the 2005 driver is Http://www.microsoft.com/downloads/details.aspx?Fa ....
(3) Add three jar files to the environment variable. For example, my installation path is D:\program Files\Microsoft SQL Server jdbcdrive, then my setting in Classpath is.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar;%catalina_home%\lib\servlet-api.jar; C:\Program Files\java\jre1.6.0\bin; C:\Program Files\Microsoft SQL Server Driver for Jdbc\lib\msbase.jar; C:\Program Files\Microsoft SQL Server Driver for Jdbc\lib\mssqlserver.jar; C:\Program Files\Microsoft SQL Server Driver for Jdbc\lib\msutil.jar;
The latter three are JDBC.
(4) Try to test the connection of the database at the command line.
Import java.sql.*;
public class TestDB {
public static void Main (string[] args) {
String drivername = "Com.microsoft.jdbc.sqlserver.SQLServerDriver";
String Dburl = "jdbc:microsoft:sqlserver://localhost:1433;databasename=master;user=sa;password=19851005";
Connection Dbconn;
try {
Class.forName (drivername);
Dbconn = Drivermanager.getconnection (Dburl);
System.out.println ("Connection successful!");
catch (Exception e) {
E.printstacktrace ();
}
}
}
Paste the above code down, save it as Testdb.java, and run it. If the result is "Connection successful!," then you are configured to succeed. I have a lot of problems in the configuration, such as:
1. Java.lang.ClassNotFoundException:com.microsoft.jdbc.sqlserver.SQLServerDriver:
Specific solutions can refer to: http://www.cnblogs.com/adandelion/archive/2005/12/...
2, SQL Server "Error establishing Socket":
Specific solutions can refer to: HTTP://BLOG.CSDN.NET/SOFTWAVE/ARCHIVE/2006/11/08/1 ...
3. User ' sa ' login failed. This user is not associated with a trusted SQL Server connection:
Specific solutions can be referred to: http://www.wansky.cn/blog/article.asp?id=130
If not resolved, then www.google.com and www.baidu.com can solve this problem, another good site is http://dev.cbw.com/sql/, in which there are a lot of experts to solve the problem.
(5) below begins the configuration of JDBC within Eclipse.
(6) If you encounter the same error in the following (4), see the above solution.
Step three: The configuration of the JSP, servlet, and JavaBean environments under Tomcat:
The following article has very detailed introduction http://www.itpub.net/345002,1.html, may refer to.
Step four: Database connections under Tomcat and JDBC loading:
- This article describes the Setup http://bbs.51cto.com/archiver/tid-38247.html for Tomcat under data source. Be sure to download the admin package under Tomcat first. Google or Baidu is not easy to find the download of the address, so I prefer to use the North Skynet search, the address is http://file.tianwang.com/cgi-bin/search?word=apach ... can choose their own suitable. My Tomcat version here is 6.0, but admin doesn't seem to have a high version (maybe, but I didn't find one), so I can get the next slightly higher version. Follow the admin configuration for Tomcat as described in the above article.
- The following article describes how to specifically configure Jdbc:http://dev2dev.bea.com.cn/bbs/thread.jspa?forumid= ....
The configuration of the whole process is still quite complicated, but after finishing it is quite a sense of achievement. Oh, hehe ...