JSP MS SQL Server Database Connection

xiaoxiao2021-03-06  122

<% @ Page ContentType = "Text / HTML; Charset = GB2312"%> <% @ page import = "java.sql. *"%> <% class.Forname ("com.microsoft.jdbc .sqlserver.sqlserdriver "). NewInstance (); string url =" JDBC: Microsoft: SQLServer: // localhost: 1433; DatabaseName = km_news;

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 KM_News "; ResultSet RS = Stmt.executeQuery (SQL); while (rs.next ()) {%> ÄúμÄμäòò» ¸ £ × ö¶îîäèýªªª £ o <% = rgetsª (1)%> Äúμäμúþþþþ × ö¶îääèýªª £ o <% = rs.getstring (2)%> <%}%> <% out.print ("ý¾/4ý¿2ù × 3¹ ¹ ¹ £ ¬¹¬¹ï2äã");%> <% r. Close (); stmt.close (); conn.close ();%>

转载请注明原文地址:https://www.9cbs.com/read-126375.html

New Post(0)