data record:
1 bitan bbbbbbbbbbbbbb 0x00000000000000CA2 Helen Hhhhhhhhh 0x00000000000000CB3 Susan sssssssss 0x00000000000000CC4 Kathy Kkkkkkkkkk 0x00000000000000CD
K: /jboss/server/default/deploy/msql-ds.xml:
XML Version = "1.0" encoding = "uTF-8"?>
Copy the three drivers of SQLSERVER for JDBC to
K: / JBoss / Server / Default / LIB
K: /jboss/server/default/deploy/test1.war/t1.jsp
<% @ Page ContentType = "Text / HTML; Charset = GBK"%> <% @ page import = "java.sql. *"%> <% try {javax.naming.initialcontext ic = new javax.naming.initialcontext ); Javax.sql.datasource DS = (javax.sql.datasource) Ic.lookup ("java: / mssqlserver"); connection conn = ds.getConnection (); statement stmt = conn.createstatement (); for (ResultSet RS) = Stmt.executeQuery ("Select * from users"); rs.next ();) {INT ID = rs.getinT (1); string name = rs.getstring (2); string password = rs.getstring (3) String time = rs.getstring (4); out.println ("id =" ID "name =" Name "password =" password "time =" TIME "
"); }}} Catch (java.sql.sqlexception se) {} catch (javax.naming.namingexception ne) {}%> Result:
Http: // localhost: 4000 / TEST1 / T1.JSP
id = 1 name = bitan password = bbbbbbbbbbb time = 00000000000000CAid = 2 name = helen password = hhhhhhhhhhh time = 00000000000000CBid = 3 name = susan password = ssssssssss time = 00000000000000CCid = 4 name = kathy password = kkkkkkkkkk time = 00000000000000CD