当前位置: 代码迷 >> Java Web开发 >> 焦急 高手看看 JS结合JvavaScriopt查询数据并且用表格显示出来
  详细解决方案

焦急 高手看看 JS结合JvavaScriopt查询数据并且用表格显示出来

热度:247   发布时间:2016-04-17 14:45:07.0
着急 高手看看 JS结合JvavaScriopt查询数据并且用表格显示出来
<%@page   language= "java "   contentType= "text/html;charset=gb2312 "%>  
<!--告诉编译器使用SQL包-->
<%@   page   import= "java.util.* "%>
<%@   page   import= "java.sql.* "%>
<html>  
<head> <title> jsp实例 </title>  
<%  
String   col2= " ";
String   shtml= " ";
String   sSQL= " ";
String   fullsrc= " ";
String   src   =   "http://127.0.0.1:9009?id= ";
try
{
Connection   con;
Statement   stmt;
ResultSet   rs;    
//加载驱动程序,下面的代码为加载JDBD-ODBC驱动程序
Class.forName( "oracle.jdbc.driver.OracleDriver ").newInstance();
//用适当的驱动程序连接到数据库,test "是系统dsn名
String   url= "jdbc:oracle:thin:@192.168.1.110:1521:ora9i ";
String   User   =   "gaczdata0004 ";
String   PWD   =   "gold ";
//建立连接,类似于ASP中的创建数据库联接
con=DriverManager.getConnection(url,   User,   PWD);
//创建一个JDBC声明
stmt   =   con.createStatement();
//增加新记录
//stmt.executeUpdate( "INSERT   INTO   test   (a,b)   VALUES   (1, "2 ") ");
//查询记录
sSQL   =   "select   co.COMPANY_NAME,ca.ASSET_CARD_NO,ca.ASSET_CARD_NAME,da.DEPARTMENT_NAME,pe.FIRST_NAME   ||   pe.LAST_NAME   as ";
        sSQL   =   sSQL   +   "   Name,us.USER_NAME   FROM   COMPANY   co,ZC_ASSET_CARD   ca,DEPARTMENT   da,PERSON   pe,USER_LOGIN   us   where   ";
sSQL   =   sSQL   +   "co.COMPANY_PARTY_ID   =   ca.COMPANY_PARTY_ID   and   da.DEPARTMENT_PARTY_ID   =   ca.DEPARTMENT_ID   and   ";
sSQL   =   sSQL   +   "pe.PARTY_ID=ca.EMPLOYEE_ID   and   us.USER_LOGIN_ID   =   ca.FH_USER_LOGIN_ID   and   ca.FH_USER_LOGIN_ID   <> 'null ' ";

//sSQL   = "select   co.COMPANY_NAME,ca.ASSET_CARD_NO   from     COMPANY   co,ZC_ASSET_CARD   ca ";
rs   =   stmt.executeQuery(sSQL);

  //sSQL   =   "select   co.COMPANY_NAME,ca.ASSET_CARD_NO,ca.ASSET_CARD_NAME,da.DEPARTMENT_NAME,pe.FIRST_NAME   ||   pe.LAST_NAME   as ";
  //sSQL   =   sSQL   +   "   Name,us.USER_NAME   FROM   COMPANY   co,ZC_ASSET_CARD   ca,DEPARTMENT   da,PERSON   pe,USER_LOGIN   us ";
 
  rs   =   stmt.executeQuery(sSQL);
//输出查询结果

        shtml   =   " <div   style=\ "height:16px;   width:80%;   color:white;background-color:blue;\ "> ";
shtml   +=   " <table   width= '80% '> <tr> <td> <font   style=\ "font-size:14px;color:white;   width:30%;   align:left;\ "> ";
shtml   +=   "查询结果 </font> </td> <td> ";
shtml   +=   " <a   href= 'http://127.0.0.1:9090/QueryDataRight1.html '> <font   style=\ "font-size:14px;   color:white;   ";
shtml   +=   "width:70%;align:right;\ "> 返回 ";
shtml   +=   " </font> </a> </td> </tr> </table> </div> ";
        shtml   +=   " <div> <table   width= '80% '   style=\ "border:1   ;cellpadding=0   ;cellspacing=1   ;bgcolor== 'black '\ "> ";