多数据源

1、JNDI查找数据源

http://blog.sina.com.cn/s/blog_4d6fba1b0100muct.html


2、

<%

DataSource ds = null;
InitialContext ctx=new InitialContext();    
ds=(DataSource)ctx.lookup("java:comp/env/jdbc/sqlserver");    
Connection conn = ds.getConnection();   
%>
  <%
Statement stmt=conn.createStatement();
String sql_gun="select * from sm_t_salesheet" ;
ResultSet rs_gun=stmt.executeQuery(sql_gun);
  while(rs_gun.next())
  {
%>
  <%=rs_gun.getString("sheet_no")%>
<%
}
rs_gun.close();
stmt.close();
%>

<%conn.close(); %>


<%
DataSource ds2 = null;
InitialContext ctx2=new InitialContext();    
ds2=(DataSource)ctx.lookup("java:comp/env/jdbc/mysql");    
Connection conn2 = ds2.getConnection();   
%>
<%
Statement stmt2=conn2.createStatement();
String sql_gun2="select * from sm_t_salesheet" ;
ResultSet rs_gun2=stmt2.executeQuery(sql_gun2);
  while(rs_gun2.next())
  {
%>
  <%=rs_gun2.getString("sheet_no")%>
<%
}
rs_gun2.close();
stmt2.close();
%>

<%conn2.close(); %>



参考:http://thinkingforward.iteye.com/blog/1447920

posted on 2015-06-05 15:25  _故乡的原风景  阅读(90)  评论(0编辑  收藏  举报