ITeye博客

websphere JVM trace.log jndi datasource

雨中伞 · 2010-04-30 01:15 · 综合编程 · 编程语言 · SQL Server · JDBC · JVM · Oracle · Websphere · Markdown

引用 websphere datasource 
<resource-ref>
	<description>Datasource</description>
	<res-ref-name>jdbc/oracle</res-ref-name>
	<res-type>javax.sql.DataSource</res-type>
	<res-auth>Container</res-auth>
</resource-ref>	

 

   Properties properties = new Properties();
			properties.put(Context.INITIAL_CONTEXT_FACTORY, "com.ibm.websphere.naming.WsnInitialContextFactory");
			properties.put(Context.PROVIDER_URL, "iiop://localhost:2809");
			Context ctx = new InitialContext(properties);
			DataSource ds = (DataSource) ctx.lookup("jdbc/Oracle");
			
			Connection conn = ds.getConnection();
			out.println(conn + "<br>");
			
			conn.setAutoCommit(false);
			String query = "select sysdate from dual";
			ResultSet rs = null;
			PreparedStatement ps = conn.prepareStatement(query);
			rs = ps.executeQuery();
			while(rs.next()){
				out.println((java.util.Date)rs.getDate(1) + "<br>" );
			}
			conn.commit();
			rs.close();
			ps.close();
			conn.close();

 JVM :应用服务器 -->server-->服务基础架构-->进程定义-->JVM  256 512

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。