Here you can find the source of initDataSource()
Parameter | Description |
---|---|
NamingException | an exception |
private static void initDataSource() throws NamingException
//package com.java2s; //License from project: Mozilla Public License import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.sql.DataSource; public class Main { /** */// ww w . j av a 2s. co m private static DataSource dataSource = null; /** * * @throws NamingException */ private static void initDataSource() throws NamingException { Context initContext = new InitialContext(); Context context = (Context) initContext.lookup("java:comp/env"); DataSource ds = (javax.sql.DataSource) context.lookup("jdbc/webrod"); dataSource = ds; } }