1. Configure the driver of JDBC on SQL Server: Download driver on Microsoft (I downloaded SP1, still available). After installation, install "Install" / Microsoft SQL Server 2000
The three files under driver for jdbc / lib "Under" Install Directory //java/j2re1.5.0/lib/ext/ ", it is OK. Second, JSP Note Writing: 1. <% - Comment -%> 2. <% / * Comment content * /%> 3. <% file: // Comment content%> 4. 3, JSP simple database operation 1. Operation Returns the data of the data set (ie, search) file: // loads the drive class.forname ("com.microsoft.jdbc.sqlser.sqlserverdriver). NewInStance (); file: // Connect String Url =" JDBC: Microsoft: SQLServer : // localhost: 1433; DatabaseName = databasename "; String user =" sa "; String password =" "; Connection conn = DriverManager.getConnection (url, user, password); // Statement stmt = conn.createStatement (ResultSet. TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); String sql = "SELECT * FROM tablename"; ResultSet rs = stmt.executeQuery (sql); while (rs.next ()) {out.println (rs.getString ( "fieldname")); } Rs.close (); stmt.close (); conn.close (); 2. Operation has no returned SQL (Insert, Update, Delete, etc.) file: // Load Drive Class.Forname ("com.microsoft.jdbc) . SQLServer.sqlserdriver "). newInstance (); file: // Connect string url =" JDBC: Microsoft: SQLSERVER: // localhost: 1433; databasename = DatabaseName "; string user =" sa "; string password ="; " Connection conn = DriverManager.getConnection (url, user, password); // Statement stmt = conn.createStatement (ResultSet.TYPE_SCROLL_SENSITIVE, ResultSet.CONCUR_UPDATABLE); String sql = "INSERT INTO tablename (fieldname1, ...) VALUES (value1, ... ) "; Stmt.executeUpdate (SQL); stmt.close (); conn.close (); four, jsp Take the pass value Request.getParameter (" Passage Name)); V. JSP-Patent Value Chinese Code Problem Description : The Chinese value passed by JSP is not Chinese, so the value passed through the conversion.
File: // Temp is a temporary variable, strrequest is the converted string byte [] Temp = Request.getParameter ("ISO-8859-1"); string strrequest = new string (TEMP ); 6, JSP call javabeanfile: //testbean.javaPackage cxj; public class testbean {file: // Constructor PUBLIC TESTBEAN () {} public void Hello () {Out.println ("Hello");}} then use Javaac.exe compiles, generates a class file, saved to "website directory -> web-inf-> classes-> cxj" next: //test.jsp file (call file)